mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-01-14 15:52:44 +05:30
Display bsod for failed oauth requests
This commit is contained in:
parent
f10bfa894b
commit
3d8c646a94
@ -4,6 +4,7 @@ import { updateUser, logout as logoutUser, acceptRules as userAcceptRules, authe
|
||||
import authentication from 'services/api/authentication';
|
||||
import oauth from 'services/api/oauth';
|
||||
import signup from 'services/api/signup';
|
||||
import dispatchBsod from 'components/ui/bsod/dispatchBsod';
|
||||
|
||||
export function login({login = '', password = '', rememberMe = false}) {
|
||||
const PASSWORD_REQUIRED = 'error.password_required';
|
||||
@ -166,16 +167,20 @@ export function oAuthComplete(params = {}) {
|
||||
}, (resp) => {
|
||||
if (resp.acceptRequired) {
|
||||
dispatch(requirePermissionsAccept());
|
||||
}
|
||||
|
||||
return handleOauthParamsValidation(resp);
|
||||
return Promise.reject(resp);
|
||||
} else {
|
||||
return handleOauthParamsValidation(resp);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
function handleOauthParamsValidation(resp = {}) {
|
||||
/* eslint no-alert: "off" */
|
||||
resp.userMessage && alert(resp.userMessage);
|
||||
dispatchBsod();
|
||||
|
||||
// eslint-disable-next-line no-alert
|
||||
resp.userMessage && setTimeout(() => alert(resp.userMessage), 500); // 500 ms to allow re-render
|
||||
|
||||
return Promise.reject(resp);
|
||||
}
|
||||
|
@ -51,19 +51,15 @@ function getOAuthRequest(oauthData) {
|
||||
}
|
||||
|
||||
function handleOauthParamsValidation(resp = {}) {
|
||||
let userMessage;
|
||||
|
||||
if (resp.statusCode === 400 && resp.error === 'invalid_request') {
|
||||
userMessage = `Invalid request (${resp.parameter} required).`;
|
||||
resp.userMessage = `Invalid request (${resp.parameter} required).`;
|
||||
} else if (resp.statusCode === 400 && resp.error === 'unsupported_response_type') {
|
||||
userMessage = `Invalid response type '${resp.parameter}'.`;
|
||||
resp.userMessage = `Invalid response type '${resp.parameter}'.`;
|
||||
} else if (resp.statusCode === 400 && resp.error === 'invalid_scope') {
|
||||
userMessage = `Invalid scope '${resp.parameter}'.`;
|
||||
resp.userMessage = `Invalid scope '${resp.parameter}'.`;
|
||||
} else if (resp.statusCode === 401 && resp.error === 'invalid_client') {
|
||||
userMessage = 'Can not find application you are trying to authorize.';
|
||||
} else {
|
||||
return;
|
||||
resp.userMessage = 'Can not find application you are trying to authorize.';
|
||||
}
|
||||
|
||||
return Promise.reject(userMessage);
|
||||
return Promise.reject(resp);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user