2016-05-02 13:34:23 +05:30
|
|
|
import React from 'react';
|
|
|
|
|
2019-11-11 14:10:05 +05:30
|
|
|
import { FormattedMessage as Message } from 'react-intl';
|
|
|
|
import { RelativeTime } from 'components/ui';
|
2017-05-26 00:41:57 +05:30
|
|
|
import { Link } from 'react-router-dom';
|
2016-05-02 13:34:23 +05:30
|
|
|
|
2016-05-15 02:23:58 +05:30
|
|
|
import messages from './errorsDict.intl.json';
|
2016-05-02 13:34:23 +05:30
|
|
|
|
2016-08-05 11:11:33 +05:30
|
|
|
/* eslint-disable react/prop-types, react/display-name, react/no-multi-comp, no-use-before-define */
|
|
|
|
|
2016-05-02 13:34:23 +05:30
|
|
|
export default {
|
|
|
|
resolve(error) {
|
2016-05-22 19:31:31 +05:30
|
|
|
let payload = {};
|
|
|
|
|
|
|
|
if (error.type) {
|
2016-05-22 20:46:51 +05:30
|
|
|
payload = error.payload || {};
|
2016-05-22 19:31:31 +05:30
|
|
|
error = error.type;
|
|
|
|
}
|
|
|
|
return errorsMap[error] ? errorsMap[error](payload) : error;
|
2016-05-02 13:34:23 +05:30
|
|
|
}
|
2016-05-02 14:50:50 +05:30
|
|
|
};
|
2016-05-02 13:34:23 +05:30
|
|
|
|
|
|
|
const errorsMap = {
|
|
|
|
'error.login_required': () => <Message {...messages.loginRequired} />,
|
|
|
|
'error.login_not_exist': () => <Message {...messages.loginNotExist} />,
|
|
|
|
'error.password_required': () => <Message {...messages.passwordRequired} />,
|
|
|
|
|
2016-07-28 10:14:16 +05:30
|
|
|
'error.password_incorrect': (props = {}) => (
|
|
|
|
// props are handled in validationErrorsHandler in components/auth/actions
|
2016-05-02 13:34:23 +05:30
|
|
|
<span>
|
|
|
|
<Message {...messages.invalidPassword} />
|
2016-05-22 20:46:51 +05:30
|
|
|
{props.isGuest ? errorsMap.suggestResetPassword() : null}
|
2016-05-02 13:34:23 +05:30
|
|
|
</span>
|
|
|
|
),
|
|
|
|
|
|
|
|
'error.username_required': () => <Message {...messages.usernameRequired} />,
|
2016-05-10 10:00:43 +05:30
|
|
|
'error.username_invalid': () => <Message {...messages.usernameInvalid} />,
|
|
|
|
'error.username_too_short': () => <Message {...messages.usernameTooShort} />,
|
|
|
|
'error.username_too_long': () => <Message {...messages.usernameTooLong} />,
|
2016-05-02 18:43:18 +05:30
|
|
|
'error.username_not_available': () => <Message {...messages.usernameUnavailable} />,
|
2016-05-10 10:00:43 +05:30
|
|
|
|
2016-05-02 13:34:23 +05:30
|
|
|
'error.email_required': () => <Message {...messages.emailRequired} />,
|
2016-05-10 10:00:43 +05:30
|
|
|
'error.email_too_long': () => <Message {...messages.emailToLong} />,
|
2016-05-02 13:34:23 +05:30
|
|
|
'error.email_invalid': () => <Message {...messages.emailInvalid} />,
|
|
|
|
'error.email_is_tempmail': () => <Message {...messages.emailIsTempmail} />,
|
2016-07-28 10:14:16 +05:30
|
|
|
'error.email_not_available': (props = {}) => (
|
|
|
|
// props are handled in validationErrorsHandler in components/auth/actions
|
2016-05-02 13:34:23 +05:30
|
|
|
<span>
|
|
|
|
<Message {...messages.emailNotAvailable} />
|
2016-05-22 20:46:51 +05:30
|
|
|
{props.isGuest ? errorsMap.suggestResetPassword() : null}
|
2016-05-02 13:34:23 +05:30
|
|
|
</span>
|
|
|
|
),
|
|
|
|
|
2017-08-20 21:15:21 +05:30
|
|
|
'error.totp_required': () => <Message {...messages.totpRequired} />,
|
|
|
|
'error.totp_incorrect': () => <Message {...messages.totpIncorrect} />,
|
|
|
|
'error.otp_already_enabled': () => <Message {...messages.mfaAlreadyEnabled} />,
|
|
|
|
|
2016-05-02 13:34:23 +05:30
|
|
|
'error.rePassword_required': () => <Message {...messages.rePasswordRequired} />,
|
|
|
|
'error.password_too_short': () => <Message {...messages.passwordTooShort} />,
|
|
|
|
'error.rePassword_does_not_match': () => <Message {...messages.passwordsDoesNotMatch} />,
|
|
|
|
'error.rulesAgreement_required': () => <Message {...messages.rulesAgreementRequired} />,
|
|
|
|
'error.key_required': () => <Message {...messages.keyRequired} />,
|
2016-05-22 20:46:51 +05:30
|
|
|
'error.key_not_exists': (props) => (
|
|
|
|
<span>
|
|
|
|
<Message {...messages.keyNotExists} />
|
|
|
|
{props.repeatUrl ? errorsMap.resendKey(props.repeatUrl) : null}
|
|
|
|
</span>
|
|
|
|
),
|
|
|
|
'error.key_expire': (props) => errorsMap['error.key_not_exists'](props),
|
2016-05-02 13:34:23 +05:30
|
|
|
|
|
|
|
'error.newPassword_required': () => <Message {...messages.newPasswordRequired} />,
|
|
|
|
'error.newRePassword_required': () => <Message {...messages.newRePasswordRequired} />,
|
2016-05-15 02:23:58 +05:30
|
|
|
|
|
|
|
'error.account_not_activated': () => <Message {...messages.accountNotActivated} />,
|
2016-08-23 04:24:51 +05:30
|
|
|
'error.account_banned': () => <Message {...messages.accountBanned} />,
|
2016-05-15 02:23:58 +05:30
|
|
|
|
2017-06-08 00:10:44 +05:30
|
|
|
'error.recently_sent_message': (props) => (
|
|
|
|
<Message {...messages.emailFrequency} values={{
|
|
|
|
// for msLeft @see AuthError.jsx
|
2019-11-11 14:10:05 +05:30
|
|
|
time: <RelativeTime value={props.msLeft} />
|
2017-06-08 00:10:44 +05:30
|
|
|
}} />
|
|
|
|
),
|
2016-05-22 20:46:51 +05:30
|
|
|
|
2016-05-23 23:49:07 +05:30
|
|
|
'error.email_not_found': () => <Message {...messages.emailNotFound} />,
|
|
|
|
'error.account_already_activated': () => <Message {...messages.accountAlreadyActivated} />,
|
|
|
|
|
2016-08-05 11:11:33 +05:30
|
|
|
'error.captcha_required': () => <Message {...messages.captchaRequired} />,
|
2016-08-14 15:40:59 +05:30
|
|
|
'error.captcha_invalid': () => errorsMap['error.captcha_required'](),
|
2016-08-05 11:11:33 +05:30
|
|
|
|
2018-03-26 00:46:45 +05:30
|
|
|
'error.redirectUri_required': () => <Message {...messages.redirectUriRequired} />,
|
|
|
|
'error.redirectUri_invalid': () => <Message {...messages.redirectUriInvalid} />,
|
|
|
|
|
2016-05-22 20:46:51 +05:30
|
|
|
suggestResetPassword: () => (
|
|
|
|
<span>
|
|
|
|
<br/>
|
|
|
|
<Message {...messages.suggestResetPassword} values={{
|
2019-03-10 05:34:14 +05:30
|
|
|
forgotYourPassword: (
|
2016-05-22 20:46:51 +05:30
|
|
|
<Link to="/forgot-password">
|
2019-03-10 05:34:14 +05:30
|
|
|
<Message {...messages.forgotYourPassword} />
|
2016-05-22 20:46:51 +05:30
|
|
|
</Link>
|
|
|
|
)
|
|
|
|
}} />
|
|
|
|
</span>
|
|
|
|
),
|
|
|
|
|
|
|
|
resendKey: (url) => (
|
|
|
|
<span>
|
|
|
|
{' '}
|
|
|
|
<Link to={url}>
|
|
|
|
<Message {...messages.doYouWantRequestKey} />
|
|
|
|
</Link>
|
|
|
|
</span>
|
|
|
|
)
|
2016-05-02 13:34:23 +05:30
|
|
|
};
|