mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-01-15 00:02:30 +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 authentication from 'services/api/authentication';
|
||||||
import oauth from 'services/api/oauth';
|
import oauth from 'services/api/oauth';
|
||||||
import signup from 'services/api/signup';
|
import signup from 'services/api/signup';
|
||||||
|
import dispatchBsod from 'components/ui/bsod/dispatchBsod';
|
||||||
|
|
||||||
export function login({login = '', password = '', rememberMe = false}) {
|
export function login({login = '', password = '', rememberMe = false}) {
|
||||||
const PASSWORD_REQUIRED = 'error.password_required';
|
const PASSWORD_REQUIRED = 'error.password_required';
|
||||||
@ -166,16 +167,20 @@ export function oAuthComplete(params = {}) {
|
|||||||
}, (resp) => {
|
}, (resp) => {
|
||||||
if (resp.acceptRequired) {
|
if (resp.acceptRequired) {
|
||||||
dispatch(requirePermissionsAccept());
|
dispatch(requirePermissionsAccept());
|
||||||
}
|
|
||||||
|
|
||||||
return handleOauthParamsValidation(resp);
|
return Promise.reject(resp);
|
||||||
|
} else {
|
||||||
|
return handleOauthParamsValidation(resp);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleOauthParamsValidation(resp = {}) {
|
function handleOauthParamsValidation(resp = {}) {
|
||||||
/* eslint no-alert: "off" */
|
dispatchBsod();
|
||||||
resp.userMessage && alert(resp.userMessage);
|
|
||||||
|
// eslint-disable-next-line no-alert
|
||||||
|
resp.userMessage && setTimeout(() => alert(resp.userMessage), 500); // 500 ms to allow re-render
|
||||||
|
|
||||||
return Promise.reject(resp);
|
return Promise.reject(resp);
|
||||||
}
|
}
|
||||||
|
@ -51,19 +51,15 @@ function getOAuthRequest(oauthData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleOauthParamsValidation(resp = {}) {
|
function handleOauthParamsValidation(resp = {}) {
|
||||||
let userMessage;
|
|
||||||
|
|
||||||
if (resp.statusCode === 400 && resp.error === 'invalid_request') {
|
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') {
|
} 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') {
|
} 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') {
|
} else if (resp.statusCode === 401 && resp.error === 'invalid_client') {
|
||||||
userMessage = 'Can not find application you are trying to authorize.';
|
resp.userMessage = 'Can not find application you are trying to authorize.';
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.reject(userMessage);
|
return Promise.reject(resp);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user