- updated login flow;
This commit is contained in:
@@ -78,10 +78,10 @@ export default class AuthenticationService {
|
||||
};
|
||||
|
||||
static validateNewUser = (token, callback, errCallback) => {
|
||||
NetworkService.get(`${API_BASE_URL}/user/sso/validate/new-user/${token}`, callback, errCallback);
|
||||
NetworkService.unauthorizedGet(`${API_BASE_URL}/user/sso/validate/new-user/${token}`, callback, errCallback);
|
||||
};
|
||||
|
||||
static validateExistingUser = (token, callback, errCallback) => {
|
||||
NetworkService.get(`${API_BASE_URL}/user/sso/validate/existing-user/${token}`, callback, errCallback);
|
||||
NetworkService.unauthorizedGet(`${API_BASE_URL}/user/sso/validate/existing-user/${token}`, callback, errCallback);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -148,6 +148,30 @@ export class NetworkService {
|
||||
.catch(err => errorCallback(err));
|
||||
};
|
||||
|
||||
static unauthorizedGet = (url, callback, errorCallback) => {
|
||||
fetch(url, {
|
||||
method: 'GET',
|
||||
mode: 'cors',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
.then(async response => {
|
||||
let status = response.status;
|
||||
this.logApiError(url, status);
|
||||
return { response: await response.json(), status: status }
|
||||
})
|
||||
.then(data => {
|
||||
if (data.status >= 400 && data.status <= 599) {
|
||||
errorCallback(data.response);
|
||||
this.logApiError(url, data.status, data.response);
|
||||
} else {
|
||||
callback(data.response)
|
||||
}
|
||||
})
|
||||
.catch(err => errorCallback(err));
|
||||
};
|
||||
|
||||
static unauthorizedPost = (url, body, callback, errorCallback, queryParams) => {
|
||||
if (queryParams) {
|
||||
url += '?'
|
||||
|
||||
Reference in New Issue
Block a user