From 48e87c4659fcc7b2a92ba127eff7513c3f54f45b Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 22 Nov 2017 12:22:27 -0300 Subject: [PATCH] Updating contations and deleting legacy code --- client/coral-embed-stream/src/actions/auth.js | 33 ++----------------- .../client/components/ChangeUsername.js | 2 -- 2 files changed, 3 insertions(+), 32 deletions(-) diff --git a/client/coral-embed-stream/src/actions/auth.js b/client/coral-embed-stream/src/actions/auth.js index 72a6ef3bd..b0fc61e0b 100644 --- a/client/coral-embed-stream/src/actions/auth.js +++ b/client/coral-embed-stream/src/actions/auth.js @@ -2,7 +2,6 @@ import jwtDecode from 'jwt-decode'; import bowser from 'bowser'; import * as actions from '../constants/auth'; import {notify} from 'coral-framework/actions/notification'; -import {can} from 'coral-framework/services/perms'; import t from 'coral-framework/services/i18n'; import get from 'lodash/get'; @@ -36,45 +35,19 @@ export const blurSignInDialog = () => ({ type: actions.BLUR_SIGNIN_DIALOG, }); -export const createUsernameRequest = () => ({ - type: actions.CREATE_USERNAME_REQUEST -}); export const showCreateUsernameDialog = () => ({ type: actions.SHOW_CREATEUSERNAME_DIALOG }); + export const hideCreateUsernameDialog = () => ({ type: actions.HIDE_CREATEUSERNAME_DIALOG }); -const createUsernameSuccess = () => ({ - type: actions.CREATE_USERNAME_SUCCESS -}); - -const createUsernameFailure = (error) => ({ - type: actions.CREATE_USERNAME_FAILURE, - error -}); - export const updateUsername = ({username}) => ({ type: actions.UPDATE_USERNAME, username }); -export const createUsername = (userId, formData) => (dispatch, _, {rest}) => { - dispatch(createUsernameRequest()); - rest('/account/username', {method: 'PUT', body: formData}) - .then(() => { - dispatch(createUsernameSuccess()); - dispatch(hideCreateUsernameDialog()); - dispatch(updateUsername(formData)); - }) - .catch((error) => { - console.error(error); - const errorMessage = error.translation_key ? t(`error.${error.translation_key}`) : error.toString(); - dispatch(createUsernameFailure(errorMessage)); - }); -}; - export const changeView = (view) => (dispatch) => { dispatch({ type: actions.CHANGE_VIEW, @@ -322,8 +295,8 @@ export const checkLogin = () => (dispatch, _, {rest, client, pym, storage}) => { dispatch(checkLoginSuccess(result.user)); pym.sendMessage('coral-auth-changed', JSON.stringify(result.user)); - // Display create username dialog if necessary. - if (can(result.user, 'EDIT_NAME') && get(result.user, 'status.banned.status')) { + // This is for login via social. Usernames should be set. + if (get(result.user, 'status.username.status') === 'UNSET' && !get(result.user, 'status.banned.status')) { dispatch(showCreateUsernameDialog()); } }) diff --git a/plugins/talk-plugin-auth/client/components/ChangeUsername.js b/plugins/talk-plugin-auth/client/components/ChangeUsername.js index af67d93bb..95f1393e9 100644 --- a/plugins/talk-plugin-auth/client/components/ChangeUsername.js +++ b/plugins/talk-plugin-auth/client/components/ChangeUsername.js @@ -15,7 +15,6 @@ import { hideCreateUsernameDialog, invalidForm, validForm, - createUsername } from 'coral-embed-stream/src/actions/auth'; class ChangeUsernameContainer extends React.Component { @@ -140,7 +139,6 @@ const mapStateToProps = ({auth}) => ({ const mapDispatchToProps = (dispatch) => bindActionCreators( { - createUsername, showCreateUsernameDialog, hideCreateUsernameDialog, invalidForm,