diff --git a/package.json b/package.json index e777d2c..f78bdea 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "up": "npm update", "test": "karma start ./karma.conf.js", "lint": "eslint ./src", - "i18n": "./node_modules/.bin/babel-node ./scripts/i18n-collect.js", + "i18n": "babel-node ./scripts/i18n-collect.js", "build": "rm -rf dist/ && webpack --progress --colors -p" }, "dependencies": { diff --git a/src/components/auth/actions.js b/src/components/auth/actions.js index d9823b3..54f8aa6 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, acceptRules as userAcceptRules } from 'components/user/actions'; +import { updateUser, logout, acceptRules as userAcceptRules } from 'components/user/actions'; import { authenticate } from 'components/accounts/actions'; import authentication from 'services/api/authentication'; import oauth from 'services/api/oauth'; @@ -24,6 +24,7 @@ export function login({login = '', password = '', rememberMe = false}) { } else if (resp.errors.login === ACTIVATION_REQUIRED) { return dispatch(needActivation()); } else if (resp.errors.login === LOGIN_REQUIRED && password) { + // TODO: log this case to backend // return to the first step return dispatch(logout()); } @@ -143,9 +144,7 @@ export function clearErrors() { return setErrors(null); } -export function logout() { - return logoutUser(); -} +export { logout, updateUser } from 'components/user/actions'; /** * @param {object} oauthData diff --git a/src/components/auth/chooseAccount/ChooseAccount.intl.json b/src/components/auth/chooseAccount/ChooseAccount.intl.json index c32f22c..9b207ca 100644 --- a/src/components/auth/chooseAccount/ChooseAccount.intl.json +++ b/src/components/auth/chooseAccount/ChooseAccount.intl.json @@ -1,5 +1,6 @@ { "chooseAccountTitle": "Choose an account", "addAccount": "Log into another account", + "logoutAll": "Log out from all accounts", "description": "You have logged in into multiple accounts. Please choose the one, you want to use to authorize {appName}" } diff --git a/src/components/auth/chooseAccount/ChooseAccount.jsx b/src/components/auth/chooseAccount/ChooseAccount.jsx index b220f7d..0aaa6de 100644 --- a/src/components/auth/chooseAccount/ChooseAccount.jsx +++ b/src/components/auth/chooseAccount/ChooseAccount.jsx @@ -7,5 +7,10 @@ export default factory({ body: Body, footer: { label: messages.addAccount - } + }, + links: [ + { + label: messages.logoutAll + } + ] }); diff --git a/src/i18n/be.json b/src/i18n/be.json index 01d6d67..1175afd 100644 --- a/src/i18n/be.json +++ b/src/i18n/be.json @@ -21,6 +21,7 @@ "components.auth.chooseAccount.addAccount": "Увайсці ў другі акаўнт", "components.auth.chooseAccount.chooseAccountTitle": "Выбар акаўнта", "components.auth.chooseAccount.description": "Вы выканалі ўваход у некалькі акаўнтаў. Пазначце, які вы жадаеце выкарыстаць для аўтарызацыі {appName}", + "components.auth.chooseAccount.logoutAll": "Log out from all accounts", "components.auth.finish.authForAppFailed": "Аўтарызацыя для {appName} не атрымалася", "components.auth.finish.authForAppSuccessful": "Аўтарызацыя для {appName} паспяхова выканана", "components.auth.finish.copy": "Скапіяваць", diff --git a/src/i18n/en.json b/src/i18n/en.json index 7ecf321..ba29676 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -21,6 +21,7 @@ "components.auth.chooseAccount.addAccount": "Log into another account", "components.auth.chooseAccount.chooseAccountTitle": "Choose an account", "components.auth.chooseAccount.description": "You have logged in into multiple accounts. Please choose the one, you want to use to authorize {appName}", + "components.auth.chooseAccount.logoutAll": "Log out from all accounts", "components.auth.finish.authForAppFailed": "Authorization for {appName} was failed", "components.auth.finish.authForAppSuccessful": "Authorization for {appName} was successfully completed", "components.auth.finish.copy": "Copy", diff --git a/src/i18n/ru.json b/src/i18n/ru.json index 05cc076..2f7a722 100644 --- a/src/i18n/ru.json +++ b/src/i18n/ru.json @@ -21,6 +21,7 @@ "components.auth.chooseAccount.addAccount": "Войти в другой аккаунт", "components.auth.chooseAccount.chooseAccountTitle": "Выбор аккаунта", "components.auth.chooseAccount.description": "Вы выполнили вход в несколько аккаунтов. Укажите, какой вы хотите использовать для авторизации {appName}", + "components.auth.chooseAccount.logoutAll": "Выйти из всех аккаунтов", "components.auth.finish.authForAppFailed": "Авторизация для {appName} не удалась", "components.auth.finish.authForAppSuccessful": "Авторизация для {appName} успешно выполнена", "components.auth.finish.copy": "Скопировать", diff --git a/src/i18n/uk.json b/src/i18n/uk.json index 0a3b7fd..7225fc1 100644 --- a/src/i18n/uk.json +++ b/src/i18n/uk.json @@ -21,6 +21,7 @@ "components.auth.chooseAccount.addAccount": "Увійти в інший акаунт", "components.auth.chooseAccount.chooseAccountTitle": "Оберіть акаунт", "components.auth.chooseAccount.description": "Ви увійшли у декілька акаунтів. Будь ласка, оберіть акаунт, який ви бажаєте використовувати для авторизації {appName}", + "components.auth.chooseAccount.logoutAll": "Вийти з усіх аккаунтів", "components.auth.finish.authForAppFailed": "Авторизація для {appName} не вдалася", "components.auth.finish.authForAppSuccessful": "Авторизація для {appName} успішно виконана", "components.auth.finish.copy": "Скопіювати", diff --git a/src/services/authFlow/ChooseAccountState.js b/src/services/authFlow/ChooseAccountState.js index 069b3a6..1ef9708 100644 --- a/src/services/authFlow/ChooseAccountState.js +++ b/src/services/authFlow/ChooseAccountState.js @@ -17,4 +17,8 @@ export default class ChooseAccountState extends AbstractState { context.setState(new LoginState()); } } + + reject(context) { + context.run('logout'); + } } diff --git a/src/services/authFlow/index.js b/src/services/authFlow/index.js index c75fd4c..8a365e3 100644 --- a/src/services/authFlow/index.js +++ b/src/services/authFlow/index.js @@ -1,11 +1,9 @@ import AuthFlow from './AuthFlow'; import * as actions from 'components/auth/actions'; -import {updateUser} from 'components/user/actions'; const availableActions = { - ...actions, - updateUser + ...actions }; export default new AuthFlow(availableActions);