mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-05-31 14:11:58 +05:30
#26: suggest resend confirmation key in validation errors
This commit is contained in:
@@ -84,7 +84,7 @@ export function recoverPassword({
|
||||
|
||||
return dispatch(authenticate(resp.jwt));
|
||||
})
|
||||
.catch(validationErrorsHandler(dispatch))
|
||||
.catch(validationErrorsHandler(dispatch, '/forgot-password'))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ export function activate({key = ''}) {
|
||||
|
||||
return dispatch(authenticate(resp.jwt));
|
||||
})
|
||||
.catch(validationErrorsHandler(dispatch))
|
||||
.catch(validationErrorsHandler(dispatch, '/reactivate'))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -332,19 +332,27 @@ function needActivation() {
|
||||
});
|
||||
}
|
||||
|
||||
function validationErrorsHandler(dispatch) {
|
||||
function validationErrorsHandler(dispatch, repeatUrl) {
|
||||
return (resp) => {
|
||||
if (resp.errors) {
|
||||
let errorMessage = resp.errors[Object.keys(resp.errors)[0]];
|
||||
const error = {
|
||||
type: resp.errors[Object.keys(resp.errors)[0]],
|
||||
payload: {
|
||||
isGuest: true
|
||||
}
|
||||
};
|
||||
|
||||
if (resp.data) {
|
||||
errorMessage = {
|
||||
type: errorMessage,
|
||||
payload: resp.data
|
||||
};
|
||||
Object.assign(error.payload, resp.data);
|
||||
}
|
||||
|
||||
dispatch(setError(errorMessage));
|
||||
return Promise.reject(errorMessage);
|
||||
if (['error.key_not_exists', 'error.key_expire'].includes(error.type) && repeatUrl) {
|
||||
Object.assign(error.payload, {
|
||||
repeatUrl
|
||||
});
|
||||
}
|
||||
|
||||
dispatch(setError(error));
|
||||
}
|
||||
|
||||
return Promise.reject(resp);
|
||||
|
||||
@@ -13,7 +13,7 @@ function resetTimer() {
|
||||
export default function AuthError({error, onClose = function() {}}) {
|
||||
resetTimer();
|
||||
|
||||
if (error.type === 'error.email_frequency') {
|
||||
if (error.payload && error.payload.canRepeatIn) {
|
||||
if (error.payload && error.payload.canRepeatIn) {
|
||||
error.payload.msLeft = error.payload.canRepeatIn * 1000;
|
||||
setTimeout(onClose, error.payload.msLeft - Date.now() + 1500); // 1500 to let the user see, that time is elapsed
|
||||
|
||||
@@ -51,6 +51,7 @@ export default class RecoverPasswordBody extends BaseAuthBody {
|
||||
required
|
||||
value={key}
|
||||
readOnly={!!key}
|
||||
autoComplete="off"
|
||||
placeholder={messages.enterTheCode}
|
||||
/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user