Обработка ошибки не активированного аккаунта

This commit is contained in:
SleepWalker 2016-02-28 13:24:47 +02:00
parent bef0910bc3
commit 17bdf52496
3 changed files with 13 additions and 4 deletions

View File

@ -2,6 +2,7 @@ import React, { PropTypes } from 'react';
import { FormattedMessage as Message } from 'react-intl'; import { FormattedMessage as Message } from 'react-intl';
import Helmet from 'react-helmet'; import Helmet from 'react-helmet';
import { Link } from 'react-router';
import buttons from 'components/ui/buttons.scss'; import buttons from 'components/ui/buttons.scss';
import { Input } from 'components/ui/Form'; import { Input } from 'components/ui/Form';
@ -75,9 +76,9 @@ export default function PasswordChange() {
</button> </button>
), ),
Links: () => ( Links: () => (
<a href="/oauth/permissions"> <Link to="/oauth/permissions">
<Message {...passwordChangedMessages.skipThisStep} /> <Message {...passwordChangedMessages.skipThisStep} />
</a> </Link>
) )
}; };
} }

View File

@ -6,6 +6,7 @@ import request from 'services/request';
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';
const LOGIN_REQUIRED = 'error.login_required'; const LOGIN_REQUIRED = 'error.login_required';
const ACTIVATION_REQUIRED = 'error.account_not_activated';
return (dispatch) => return (dispatch) =>
request.post( request.post(
@ -23,7 +24,14 @@ export function login({login = '', password = '', rememberMe = false}) {
dispatch(redirectToGoal()); dispatch(redirectToGoal());
}) })
.catch((resp) => { .catch((resp) => {
if (resp.errors.password === PASSWORD_REQUIRED) { if (resp.errors.login === ACTIVATION_REQUIRED) {
dispatch(updateUser({
isActive: false,
isGuest: false
}));
dispatch(redirectToGoal());
} else if (resp.errors.password === PASSWORD_REQUIRED) {
dispatch(updateUser({ dispatch(updateUser({
username: login, username: login,
email: login email: login

View File

@ -23,7 +23,7 @@ export default class User {
avatar: '', avatar: '',
goal: null, // the goal with wich user entered site goal: null, // the goal with wich user entered site
isGuest: true, isGuest: true,
isActive: false, isActive: true,
shouldChangePassword: false shouldChangePassword: false
}; };