- updated login flow;

This commit is contained in:
Vitalii Kiiko
2026-03-26 09:44:59 +01:00
parent f809d224e1
commit 16eb0b3f78
3 changed files with 28 additions and 3 deletions

View File

@@ -46,6 +46,7 @@ const Login = () => {
token: data.data.token,
userData: data.data.user
});
window.location.replace('/');
} else {
if (errorMsgs.current) {
errorMsgs.current.show([
@@ -99,7 +100,7 @@ const Login = () => {
useEffect(() => {
const queryParams = Object.fromEntries(searchParams);
if (!isEmpty(token) && isNil(queryParams.redirectReason)) {
if (!isEmpty(token) && isNil(queryParams.redirectReason) && isNil(queryParams.temp_token)) {
window.location.replace('/')
}
}, [token]);

View File

@@ -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);
};
}

View File

@@ -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 += '?'