From d28337cb7fc4bc6b8370f489a3fc2a0bf90ed856 Mon Sep 17 00:00:00 2001 From: SleepWalker Date: Tue, 17 Oct 2017 19:46:00 +0300 Subject: [PATCH] Fix codestyle --- src/components/auth/PanelTransition.js | 2 +- src/components/auth/actions.js | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/components/auth/PanelTransition.js b/src/components/auth/PanelTransition.js index 8f84b26..7bca9f2 100644 --- a/src/components/auth/PanelTransition.js +++ b/src/components/auth/PanelTransition.js @@ -32,7 +32,7 @@ const changeContextSpringConfig = {stiffness: 500, damping: 20, precision: 0.5}; * (e.g. the panel with lower index will slide from left side, and with greater from right side) */ const contexts = [ - ['login', 'password', 'mfa', 'forgotPassword', 'recoverPassword'], + ['login', 'password', 'forgotPassword', 'mfa', 'recoverPassword'], ['register', 'activation', 'resendActivation'], ['acceptRules'], ['chooseAccount', 'permissions'] diff --git a/src/components/auth/actions.js b/src/components/auth/actions.js index 2eb119a..2fdf594 100644 --- a/src/components/auth/actions.js +++ b/src/components/auth/actions.js @@ -46,6 +46,12 @@ export function redirect(url: string): () => Promise<*> { }); } + +const PASSWORD_REQUIRED = 'error.password_required'; +const LOGIN_REQUIRED = 'error.login_required'; +const ACTIVATION_REQUIRED = 'error.account_not_activated'; +const TOTP_REQUIRED = 'error.totp_required'; + export function login({ login = '', password = '', @@ -57,11 +63,6 @@ export function login({ totp?: string, rememberMe?: bool }) { - const PASSWORD_REQUIRED = 'error.password_required'; - const LOGIN_REQUIRED = 'error.login_required'; - const ACTIVATION_REQUIRED = 'error.account_not_activated'; - const TOTP_REQUIRED = 'error.totp_required'; - return wrapInLoader((dispatch) => authentication.login( {login, password, totp, rememberMe} @@ -86,8 +87,9 @@ export function login({ } } - return validationErrorsHandler(dispatch)(resp); + return Promise.reject(resp); }) + .catch(validationErrorsHandler(dispatch)) ); } @@ -508,7 +510,10 @@ function authHandler(dispatch) { }); } -function validationErrorsHandler(dispatch: (Function | Object) => void, repeatUrl?: string) { +function validationErrorsHandler( + dispatch: (Function | Object) => void, + repeatUrl?: string +) { return (resp) => { if (resp.errors) { const firstError = Object.keys(resp.errors)[0];