From 6c9c5de11fe5d355860f4dad329b4c98b079f607 Mon Sep 17 00:00:00 2001 From: Adeel Khan Date: Tue, 16 Feb 2021 06:41:09 +0500 Subject: [PATCH] Removes option call from multiple end points This patch removes option call not needed in certain end points via not sending csrf token. VAN-370 --- src/forgot-password/data/service.js | 5 ++--- src/register/data/service.js | 8 +++----- src/reset-password/data/service.js | 8 +++----- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/forgot-password/data/service.js b/src/forgot-password/data/service.js index 25020c56..b8f5b36d 100644 --- a/src/forgot-password/data/service.js +++ b/src/forgot-password/data/service.js @@ -1,15 +1,14 @@ import { getConfig } from '@edx/frontend-platform'; -import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth'; +import { getHttpClient } from '@edx/frontend-platform/auth'; import formurlencoded from 'form-urlencoded'; // eslint-disable-next-line import/prefer-default-export export async function forgotPassword(email) { const requestConfig = { headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, - isPublic: true, }; - const { data } = await getAuthenticatedHttpClient() + const { data } = await getHttpClient() .post( `${getConfig().LMS_BASE_URL}/account/password`, formurlencoded({ email }), diff --git a/src/register/data/service.js b/src/register/data/service.js index 7acad273..8143408d 100644 --- a/src/register/data/service.js +++ b/src/register/data/service.js @@ -1,14 +1,13 @@ import { getConfig } from '@edx/frontend-platform'; -import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth'; +import { getHttpClient } from '@edx/frontend-platform/auth'; import querystring from 'querystring'; export async function registerRequest(registrationInformation) { const requestConfig = { headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, - isPublic: true, }; - const { data } = await getAuthenticatedHttpClient() + const { data } = await getHttpClient() .post( `${getConfig().LMS_BASE_URL}/user_api/v2/account/registration/`, querystring.stringify(registrationInformation), @@ -27,10 +26,9 @@ export async function registerRequest(registrationInformation) { export async function getFieldsValidations(formPayload) { const requestConfig = { headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, - isPublic: true, }; - const { data } = await getAuthenticatedHttpClient() + const { data } = await getHttpClient() .post( `${getConfig().LMS_BASE_URL}/api/user/v1/validation/registration`, querystring.stringify(formPayload), diff --git a/src/reset-password/data/service.js b/src/reset-password/data/service.js index 8399f6dc..8a4f234e 100644 --- a/src/reset-password/data/service.js +++ b/src/reset-password/data/service.js @@ -1,15 +1,14 @@ import { getConfig } from '@edx/frontend-platform'; -import { getHttpClient, getAuthenticatedHttpClient } from '@edx/frontend-platform/auth'; +import { getHttpClient } from '@edx/frontend-platform/auth'; import formurlencoded from 'form-urlencoded'; // eslint-disable-next-line import/prefer-default-export export async function validateToken(token) { const requestConfig = { headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, - isPublic: true, }; - const { data } = await getAuthenticatedHttpClient() + const { data } = await getHttpClient() .post( `${getConfig().LMS_BASE_URL}/user_api/v1/account/password_reset/token/validate/`, formurlencoded({ token }), @@ -25,7 +24,6 @@ export async function validateToken(token) { export async function resetPassword(payload, token, queryParams) { const requestConfig = { headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, - isPublic: true, }; const url = new URL(`${getConfig().LMS_BASE_URL}/password/reset/${token}/`); @@ -33,7 +31,7 @@ export async function resetPassword(payload, token, queryParams) { url.searchParams.append('is_account_recovery', true); } - const { data } = await getAuthenticatedHttpClient() + const { data } = await getHttpClient() .post(url.href, formurlencoded(payload), requestConfig) .catch((e) => { throw (e);