Change login and registration API endpoints. (#80)
* Change login and registration API endpoints. Changed login/registration endpoints to match monolith FE. Also fixed a warning and removed an extra call to login_refresh. VAN-107 * Fix login/register redirection. VAN-12
This commit is contained in:
@@ -69,10 +69,10 @@ class LoginPage extends React.Component {
|
||||
const next = params.get('next');
|
||||
const courseId = params.get('course_id');
|
||||
if (next) {
|
||||
payload.next = params.next;
|
||||
payload.next = next;
|
||||
}
|
||||
if (courseId) {
|
||||
payload.course_id = params.course_id;
|
||||
payload.course_id = courseId;
|
||||
}
|
||||
if (!this.state.formValid) {
|
||||
this.validateInput('email', payload.email);
|
||||
@@ -179,7 +179,7 @@ class LoginPage extends React.Component {
|
||||
<div className="d-flex flex-row">
|
||||
<p>
|
||||
{intl.formatMessage(messages['logistration.first.time.here'])}
|
||||
<Hyperlink className="ml-1" href={REGISTER_PAGE}>
|
||||
<Hyperlink className="ml-1" destination={REGISTER_PAGE}>
|
||||
{intl.formatMessage(messages['logistration.create.an.account'])}.
|
||||
</Hyperlink>
|
||||
</p>
|
||||
|
||||
@@ -162,10 +162,10 @@ class RegistrationPage extends React.Component {
|
||||
const next = params.get('next');
|
||||
const courseId = params.get('course_id');
|
||||
if (next) {
|
||||
payload.next = params.next;
|
||||
payload.next = next;
|
||||
}
|
||||
if (courseId) {
|
||||
payload.course_id = params.course_id;
|
||||
payload.course_id = courseId;
|
||||
}
|
||||
|
||||
let finalValidation = this.isFormValid();
|
||||
|
||||
@@ -10,7 +10,7 @@ export async function registerRequest(registrationInformation) {
|
||||
|
||||
const { data } = await getAuthenticatedHttpClient()
|
||||
.post(
|
||||
`${getConfig().LMS_BASE_URL}/user_api/v1/account/registration/`,
|
||||
`${getConfig().LMS_BASE_URL}/user_api/v2/account/registration/`,
|
||||
querystring.stringify(registrationInformation),
|
||||
requestConfig,
|
||||
)
|
||||
@@ -32,7 +32,7 @@ export async function loginRequest(creds) {
|
||||
|
||||
const { data } = await getAuthenticatedHttpClient()
|
||||
.post(
|
||||
`${getConfig().LMS_BASE_URL}/login_ajax`,
|
||||
`${getConfig().LMS_BASE_URL}/user_api/v1/account/login_session/`,
|
||||
querystring.stringify(creds),
|
||||
requestConfig,
|
||||
)
|
||||
@@ -49,13 +49,13 @@ export async function loginRequest(creds) {
|
||||
export async function getThirdPartyAuthContext(urlParams) {
|
||||
const requestConfig = {
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
params: urlParams,
|
||||
isPublic: true,
|
||||
};
|
||||
|
||||
const { data } = await getAuthenticatedHttpClient()
|
||||
.get(
|
||||
`${getConfig().LMS_BASE_URL}/api/third_party_auth_context`,
|
||||
{ params: urlParams },
|
||||
requestConfig,
|
||||
)
|
||||
.catch((e) => {
|
||||
@@ -74,7 +74,7 @@ export async function getRegistrationForm() {
|
||||
|
||||
const { data } = await getAuthenticatedHttpClient()
|
||||
.get(
|
||||
`${getConfig().LMS_BASE_URL}/user_api/v1/account/registration/`,
|
||||
`${getConfig().LMS_BASE_URL}/user_api/v2/account/registration/`,
|
||||
requestConfig,
|
||||
)
|
||||
.catch((e) => {
|
||||
|
||||
@@ -27,15 +27,14 @@ export async function resetPassword(payload, token, queryParams) {
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
isPublic: true,
|
||||
};
|
||||
const url = new URL(`${getConfig().LMS_BASE_URL}/password/reset/${token}/`);
|
||||
|
||||
if (queryParams.is_account_recovery) {
|
||||
url.searchParams.append('is_account_recovery', true);
|
||||
}
|
||||
|
||||
let path = `password/reset/${token}/?track=pwreset`;
|
||||
path += queryParams.is_account_recovery ? '&is_account_recovery=true' : '';
|
||||
const { data } = await getAuthenticatedHttpClient()
|
||||
.post(
|
||||
`${getConfig().LMS_BASE_URL}/${path}`,
|
||||
formurlencoded(payload),
|
||||
requestConfig,
|
||||
)
|
||||
.post(url.href, formurlencoded(payload), requestConfig)
|
||||
.catch((e) => {
|
||||
throw (e);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user