From 6dcf985936b6c8f355b234e15696adf7eb7f1924 Mon Sep 17 00:00:00 2001 From: SleepWalker Date: Tue, 2 Aug 2016 22:13:11 +0300 Subject: [PATCH] Remove change password auth panel --- src/components/auth/PanelTransition.jsx | 1 - src/components/auth/README.md | 2 + src/components/auth/actions.js | 13 +-- .../changePassword/ChangePassword.intl.json | 9 -- .../auth/changePassword/ChangePassword.jsx | 16 ---- .../changePassword/ChangePasswordBody.jsx | 57 ------------ .../auth/changePassword/changePassword.scss | 16 ---- .../forgotPassword/ForgotPasswordBody.jsx | 2 - .../recoverPassword/RecoverPassword.intl.json | 3 + .../auth/recoverPassword/RecoverPassword.jsx | 3 +- .../recoverPassword/RecoverPasswordBody.jsx | 6 +- src/components/profile/Profile.intl.json | 1 - src/components/profile/Profile.jsx | 3 - src/components/user/User.js | 1 - src/components/user/actions.js | 20 ----- src/pages/profile/ChangePasswordPage.jsx | 3 +- src/routes.js | 2 - src/services/api/accounts.js | 12 --- src/services/authFlow/AuthFlow.js | 1 - src/services/authFlow/ChangePasswordState.js | 20 ----- src/services/authFlow/CompleteState.js | 3 - tests/services/authFlow/AuthFlow.test.js | 3 - .../authFlow/ChangePasswordState.test.js | 86 ------------------- tests/services/authFlow/CompleteState.test.js | 30 ------- 24 files changed, 10 insertions(+), 303 deletions(-) delete mode 100644 src/components/auth/changePassword/ChangePassword.intl.json delete mode 100644 src/components/auth/changePassword/ChangePassword.jsx delete mode 100644 src/components/auth/changePassword/ChangePasswordBody.jsx delete mode 100644 src/components/auth/changePassword/changePassword.scss delete mode 100644 src/services/authFlow/ChangePasswordState.js delete mode 100644 tests/services/authFlow/ChangePasswordState.test.js diff --git a/src/components/auth/PanelTransition.jsx b/src/components/auth/PanelTransition.jsx index dae99df..e2e122e 100644 --- a/src/components/auth/PanelTransition.jsx +++ b/src/components/auth/PanelTransition.jsx @@ -32,7 +32,6 @@ const changeContextSpringConfig = {stiffness: 500, damping: 20, precision: 0.5}; const contexts = [ ['login', 'password', 'forgotPassword', 'recoverPassword'], ['register', 'activation', 'resendActivation'], - ['changePassword'], ['acceptRules'], ['permissions'] ]; diff --git a/src/components/auth/README.md b/src/components/auth/README.md index 8dd2b60..f1447fc 100644 --- a/src/components/auth/README.md +++ b/src/components/auth/README.md @@ -10,6 +10,8 @@ To add new panel you need to: * connect component to `routes` * whatever else you need +Commit id with example: f4d315c + # TODO This flow must be simplified diff --git a/src/components/auth/actions.js b/src/components/auth/actions.js index fb122e6..a6433cd 100644 --- a/src/components/auth/actions.js +++ b/src/components/auth/actions.js @@ -1,6 +1,6 @@ import { routeActions } from 'react-router-redux'; -import { updateUser, logout as logoutUser, changePassword as changeUserPassword, acceptRules as userAcceptRules, authenticate } from 'components/user/actions'; +import { updateUser, logout as logoutUser, acceptRules as userAcceptRules, authenticate } from 'components/user/actions'; import authentication from 'services/api/authentication'; import oauth from 'services/api/oauth'; import signup from 'services/api/signup'; @@ -35,17 +35,6 @@ export function login({login = '', password = '', rememberMe = false}) { ); } -export function changePassword({ - password = '', - newPassword = '', - newRePassword = '' -}) { - return wrapInLoader((dispatch) => - dispatch(changeUserPassword({password, newPassword, newRePassword, logoutAll: false})) - .catch(validationErrorsHandler(dispatch)) - ); -} - export function acceptRules() { return wrapInLoader((dispatch) => dispatch(userAcceptRules()) diff --git a/src/components/auth/changePassword/ChangePassword.intl.json b/src/components/auth/changePassword/ChangePassword.intl.json deleted file mode 100644 index 81afbdf..0000000 --- a/src/components/auth/changePassword/ChangePassword.intl.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "changePasswordTitle": "Change password", - "changePasswordMessage": "To enhance the security of your account, please change your password.", - "skipThisStep": "Skip password changing", - "change": "Change password", - "currentPassword": "Enter current password", - "newPassword": "Enter new password", - "newRePassword": "Repeat new password" -} diff --git a/src/components/auth/changePassword/ChangePassword.jsx b/src/components/auth/changePassword/ChangePassword.jsx deleted file mode 100644 index b3236db..0000000 --- a/src/components/auth/changePassword/ChangePassword.jsx +++ /dev/null @@ -1,16 +0,0 @@ -import factory from 'components/auth/factory'; - -import Body from './ChangePasswordBody'; -import messages from './ChangePassword.intl.json'; - -export default factory({ - title: messages.changePasswordTitle, - body: Body, - footer: { - color: 'darkBlue', - label: messages.change - }, - links: { - label: messages.skipThisStep - } -}); diff --git a/src/components/auth/changePassword/ChangePasswordBody.jsx b/src/components/auth/changePassword/ChangePasswordBody.jsx deleted file mode 100644 index e4bf5f8..0000000 --- a/src/components/auth/changePassword/ChangePasswordBody.jsx +++ /dev/null @@ -1,57 +0,0 @@ -import React from 'react'; - -import { FormattedMessage as Message } from 'react-intl'; - -import { Input } from 'components/ui/form'; -import icons from 'components/ui/icons.scss'; -import BaseAuthBody from 'components/auth/BaseAuthBody'; - -import styles from './changePassword.scss'; -import messages from './ChangePassword.intl.json'; - -export default class ChangePasswordBody extends BaseAuthBody { - static displayName = 'ChangePasswordBody'; - static panelId = 'changePassword'; - - autoFocusField = 'password'; - - render() { - return ( -
- {this.renderErrors()} - -
- -
- -

- -

- - - - - - -
- ); - } -} diff --git a/src/components/auth/changePassword/changePassword.scss b/src/components/auth/changePassword/changePassword.scss deleted file mode 100644 index 1daf163..0000000 --- a/src/components/auth/changePassword/changePassword.scss +++ /dev/null @@ -1,16 +0,0 @@ -@import '~components/ui/colors.scss'; - -.descriptionText { - font-size: 15px; - line-height: 1.4; - padding-bottom: 8px; - color: #aaa; -} - -// TODO: вынести иконки такого типа в какую-то внешнюю структуру? -.security { - color: #fff; - font-size: 90px; - line-height: 1; - margin-bottom: 15px; -} diff --git a/src/components/auth/forgotPassword/ForgotPasswordBody.jsx b/src/components/auth/forgotPassword/ForgotPasswordBody.jsx index 53a936e..67f7ba1 100644 --- a/src/components/auth/forgotPassword/ForgotPasswordBody.jsx +++ b/src/components/auth/forgotPassword/ForgotPasswordBody.jsx @@ -25,8 +25,6 @@ export default class ForgotPasswordBody extends BaseAuthBody { const login = user.email || user.username || ''; const isLoginEditShown = this.state.isLoginEdit; - // TODO: нужно парсить инфу о том, какой кд у отправки кода и во сколько точно можно будет повторить - return (
{this.renderErrors()} diff --git a/src/components/auth/recoverPassword/RecoverPassword.intl.json b/src/components/auth/recoverPassword/RecoverPassword.intl.json index 918c60b..ce776a5 100644 --- a/src/components/auth/recoverPassword/RecoverPassword.intl.json +++ b/src/components/auth/recoverPassword/RecoverPassword.intl.json @@ -5,5 +5,8 @@ "messageWasSentTo": "The recovery code was sent to your E‑mail {email}.", "enterCodeBelow": "Please enter the code received into the field below:", "enterNewPasswordBelow": "Enter and repeat new password below:", + "change": "Change password", + "newPassword": "Enter new password", + "newRePassword": "Repeat new password", "enterTheCode": "Enter confirmation code" } diff --git a/src/components/auth/recoverPassword/RecoverPassword.jsx b/src/components/auth/recoverPassword/RecoverPassword.jsx index 3faf1e0..556e75e 100644 --- a/src/components/auth/recoverPassword/RecoverPassword.jsx +++ b/src/components/auth/recoverPassword/RecoverPassword.jsx @@ -1,5 +1,4 @@ import factory from 'components/auth/factory'; -import changePassword from 'components/auth/changePassword/ChangePassword.intl.json'; import messages from './RecoverPassword.intl.json'; import Body from './RecoverPasswordBody'; @@ -9,7 +8,7 @@ export default factory({ body: Body, footer: { color: 'lightViolet', - label: changePassword.change + label: messages.change }, links: { label: messages.contactSupport diff --git a/src/components/auth/recoverPassword/RecoverPasswordBody.jsx b/src/components/auth/recoverPassword/RecoverPasswordBody.jsx index 0931c92..1d35b38 100644 --- a/src/components/auth/recoverPassword/RecoverPasswordBody.jsx +++ b/src/components/auth/recoverPassword/RecoverPasswordBody.jsx @@ -4,13 +4,11 @@ import { FormattedMessage as Message } from 'react-intl'; import { Input } from 'components/ui/form'; import BaseAuthBody from 'components/auth/BaseAuthBody'; -import changePassword from 'components/auth/changePassword/ChangePassword.intl.json'; import styles from './recoverPassword.scss'; import messages from './RecoverPassword.intl.json'; // TODO: activation code field may be decoupled into common component and reused here and in activation panel -// TODO: new password fields may be decoupled into common component and reused here and in changePassword panel export default class RecoverPasswordBody extends BaseAuthBody { static displayName = 'RecoverPasswordBody'; @@ -64,7 +62,7 @@ export default class RecoverPasswordBody extends BaseAuthBody { color="lightViolet" type="password" required - placeholder={changePassword.newPassword} + placeholder={messages.newPassword} />
); diff --git a/src/components/profile/Profile.intl.json b/src/components/profile/Profile.intl.json index 19f1e69..2085c59 100644 --- a/src/components/profile/Profile.intl.json +++ b/src/components/profile/Profile.intl.json @@ -5,7 +5,6 @@ "preferencesDescription": "Here you can change the key preferences of your account. Please note that all actions must be confirmed by entering a password.", "mojangPriorityWarning": "A Mojang account with the same nickname was found. According to {rules}, account owner has the right to demand the restoration of control over nickname.", "projectRules": "project rules", - "oldHashingAlgoWarning": "Your was hashed with an old hashing algorithm.
Please, change password.", "changedAt": "Changed {at}", "disabled": "Disabled", "nickname": "Nickname", diff --git a/src/components/profile/Profile.jsx b/src/components/profile/Profile.jsx index 817917a..cece595 100644 --- a/src/components/profile/Profile.jsx +++ b/src/components/profile/Profile.jsx @@ -83,9 +83,6 @@ export default class Profile extends Component { value={) }} />} - warningMessage={user.shouldChangePassword ? ( - - ) : ''} /> - accounts.changePassword( - {password, newPassword, newRePassword, logoutAll} - ) - .then((resp) => { - dispatch(updateUser({ - shouldChangePassword: false - })); - - return resp; - }) - ; -} - export function acceptRules() { return (dispatch) => accounts.acceptRules() diff --git a/src/pages/profile/ChangePasswordPage.jsx b/src/pages/profile/ChangePasswordPage.jsx index ead9a6f..155d199 100644 --- a/src/pages/profile/ChangePasswordPage.jsx +++ b/src/pages/profile/ChangePasswordPage.jsx @@ -31,8 +31,7 @@ class ChangePasswordPage extends Component { sendData: () => accounts.changePassword(form.serialize()) }).then(() => { this.props.updateUser({ - passwordChangedAt: Date.now() / 1000, - shouldChangePassword: false + passwordChangedAt: Date.now() / 1000 }); this.context.goToProfile(); }); diff --git a/src/routes.js b/src/routes.js index 962650f..d6aa0a7 100644 --- a/src/routes.js +++ b/src/routes.js @@ -20,7 +20,6 @@ import Permissions from 'components/auth/permissions/Permissions'; import Activation from 'components/auth/activation/Activation'; import ResendActivation from 'components/auth/resendActivation/ResendActivation'; import Password from 'components/auth/password/Password'; -import ChangePassword from 'components/auth/changePassword/ChangePassword'; import AcceptRules from 'components/auth/acceptRules/AcceptRules'; import ForgotPassword from 'components/auth/forgotPassword/ForgotPassword'; import RecoverPassword from 'components/auth/recoverPassword/RecoverPassword'; @@ -62,7 +61,6 @@ export default function routesFactory(store) { - diff --git a/src/services/api/accounts.js b/src/services/api/accounts.js index 34dac16..664a690 100644 --- a/src/services/api/accounts.js +++ b/src/services/api/accounts.js @@ -5,18 +5,6 @@ export default { return request.get('/api/accounts/current'); }, - changePassword({ - password = '', - newPassword = '', - newRePassword = '', - logoutAll = true - }) { - return request.post( - '/api/accounts/change-password', - {password, newPassword, newRePassword, logoutAll} - ); - }, - acceptRules() { return request.post('/api/accounts/accept-rules'); }, diff --git a/src/services/authFlow/AuthFlow.js b/src/services/authFlow/AuthFlow.js index c7f4e5b..92438d2 100644 --- a/src/services/authFlow/AuthFlow.js +++ b/src/services/authFlow/AuthFlow.js @@ -144,7 +144,6 @@ export default class AuthFlow { case '/login': case '/password': case '/accept-rules': - case '/change-password': case '/oauth/permissions': case '/oauth/finish': this.setState(new LoginState()); diff --git a/src/services/authFlow/ChangePasswordState.js b/src/services/authFlow/ChangePasswordState.js deleted file mode 100644 index 45570b7..0000000 --- a/src/services/authFlow/ChangePasswordState.js +++ /dev/null @@ -1,20 +0,0 @@ -import AbstractState from './AbstractState'; -import CompleteState from './CompleteState'; - -export default class ChangePasswordState extends AbstractState { - enter(context) { - context.navigate('/change-password'); - } - - resolve(context, payload) { - context.run('changePassword', payload) - .then(() => context.setState(new CompleteState())); - } - - reject(context) { - context.run('updateUser', { - shouldChangePassword: false - }); - context.setState(new CompleteState()); - } -} diff --git a/src/services/authFlow/CompleteState.js b/src/services/authFlow/CompleteState.js index c5d68b9..248090f 100644 --- a/src/services/authFlow/CompleteState.js +++ b/src/services/authFlow/CompleteState.js @@ -2,7 +2,6 @@ import AbstractState from './AbstractState'; import LoginState from './LoginState'; import PermissionsState from './PermissionsState'; import ActivationState from './ActivationState'; -import ChangePasswordState from './ChangePasswordState'; import AcceptRulesState from './AcceptRulesState'; import FinishState from './FinishState'; @@ -22,8 +21,6 @@ export default class CompleteState extends AbstractState { context.setState(new ActivationState()); } else if (user.shouldAcceptRules) { context.setState(new AcceptRulesState()); - } else if (user.shouldChangePassword) { - context.setState(new ChangePasswordState()); } else if (auth.oauth && auth.oauth.clientId) { if (auth.oauth.code) { context.setState(new FinishState()); diff --git a/tests/services/authFlow/AuthFlow.test.js b/tests/services/authFlow/AuthFlow.test.js index 2b2c6d2..b98dc96 100644 --- a/tests/services/authFlow/AuthFlow.test.js +++ b/tests/services/authFlow/AuthFlow.test.js @@ -12,8 +12,6 @@ import ActivationState from 'services/authFlow/ActivationState'; import ResendActivationState from 'services/authFlow/ResendActivationState'; import LoginState from 'services/authFlow/LoginState'; -// TODO: navigate and state switching - describe('AuthFlow', () => { let flow; let actions; @@ -178,7 +176,6 @@ describe('AuthFlow', () => { '/': LoginState, '/login': LoginState, '/password': LoginState, - '/change-password': LoginState, '/accept-rules': LoginState, '/oauth/permissions': LoginState, '/oauth/finish': LoginState, diff --git a/tests/services/authFlow/ChangePasswordState.test.js b/tests/services/authFlow/ChangePasswordState.test.js deleted file mode 100644 index e1f3fd7..0000000 --- a/tests/services/authFlow/ChangePasswordState.test.js +++ /dev/null @@ -1,86 +0,0 @@ -import ChangePasswordState from 'services/authFlow/ChangePasswordState'; -import CompleteState from 'services/authFlow/CompleteState'; - -import { bootstrap, expectState, expectNavigate, expectRun } from './helpers'; - -describe('ChangePasswordState', () => { - let state; - let context; - let mock; - - beforeEach(() => { - state = new ChangePasswordState(); - - const data = bootstrap(); - context = data.context; - mock = data.mock; - }); - - afterEach(() => { - mock.verify(); - }); - - describe('#enter', () => { - it('should navigate to /change-password', () => { - context.getState.returns({ - user: {isGuest: true} - }); - - expectNavigate(mock, '/change-password'); - - state.enter(context); - }); - }); - - describe('#resolve', () => { - it('should call changePassword with payload', () => { - const payload = {}; - - expectRun( - mock, - 'changePassword', - sinon.match.same(payload) - ).returns({then() {}}); - - state.resolve(context, payload); - }); - - it('should transition to complete state on success', () => { - const promise = Promise.resolve(); - - mock.expects('run').returns(promise); - expectState(mock, CompleteState); - - state.resolve(context); - - return promise; - }); - - it('should NOT transition to complete state on fail', () => { - const promise = Promise.reject(); - - mock.expects('run').returns(promise); - mock.expects('setState').never(); - - state.resolve(context); - - return promise.catch(mock.verify.bind(mock)); - }); - }); - - describe('#reject', () => { - it('should transition to complete state and mark that password should not be changed', () => { - expectRun( - mock, - 'updateUser', - sinon.match({ - shouldChangePassword: false - }) - ); - - expectState(mock, CompleteState); - - state.reject(context); - }); - }); -}); diff --git a/tests/services/authFlow/CompleteState.test.js b/tests/services/authFlow/CompleteState.test.js index 4d0977f..b68b834 100644 --- a/tests/services/authFlow/CompleteState.test.js +++ b/tests/services/authFlow/CompleteState.test.js @@ -3,7 +3,6 @@ import expect from 'unexpected'; import CompleteState from 'services/authFlow/CompleteState'; import LoginState from 'services/authFlow/LoginState'; import ActivationState from 'services/authFlow/ActivationState'; -import ChangePasswordState from 'services/authFlow/ChangePasswordState'; import AcceptRulesState from 'services/authFlow/AcceptRulesState'; import FinishState from 'services/authFlow/FinishState'; import PermissionsState from 'services/authFlow/PermissionsState'; @@ -68,35 +67,6 @@ describe('CompleteState', () => { state.enter(context); }); - it('should transition to change-password if shouldChangePassword', () => { - context.getState.returns({ - user: { - shouldChangePassword: true, - isActive: true, - isGuest: false - }, - auth: {} - }); - - expectState(mock, ChangePasswordState); - - state.enter(context); - }); - - it('should transition to activation with higher priority than shouldChangePassword', () => { - context.getState.returns({ - user: { - shouldChangePassword: true, - isGuest: false - }, - auth: {} - }); - - expectState(mock, ActivationState); - - state.enter(context); - }); - it('should transition to accept-rules if shouldAcceptRules', () => { context.getState.returns({ user: {