From 4765973a58886a8938551bb33aa8828a5af31b2a Mon Sep 17 00:00:00 2001 From: gaba Date: Thu, 16 Feb 2017 16:07:19 -0800 Subject: [PATCH] Other small changes and fix bug because displayname instead displayName... --- client/coral-framework/actions/auth.js | 6 +++--- client/coral-framework/constants/auth.js | 4 ++-- client/coral-framework/reducers/auth.js | 4 ++-- services/passport.js | 2 -- services/users.js | 10 +++++----- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/client/coral-framework/actions/auth.js b/client/coral-framework/actions/auth.js index 51a06e2d7..7576478c4 100644 --- a/client/coral-framework/actions/auth.js +++ b/client/coral-framework/actions/auth.js @@ -12,8 +12,8 @@ export const createUsernameRequest = () => ({type: actions.CREATE_USERNAME_REQUE export const showCreateUsernameDialog = () => ({type: actions.SHOW_CREATEUSERNAME_DIALOG}); export const hideCreateUsernameDialog = () => ({type: actions.HIDE_CREATEUSERNAME_DIALOG}); -const createUsernameSuccess = () => ({type: actions.CREATEUSERNAME_SUCCESS}); -const createUsernameFailure = error => ({type: actions.CREATEUSERNAME_FAILURE, error}); +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}); @@ -95,7 +95,7 @@ export const fetchSignUpFacebook = () => dispatch => { export const facebookCallback = (err, data) => dispatch => { if (err) { - signInFacebookFailure(err); + dispatch(signInFacebookFailure(err)); return; } try { diff --git a/client/coral-framework/constants/auth.js b/client/coral-framework/constants/auth.js index 8ae032f0a..9a217fb43 100644 --- a/client/coral-framework/constants/auth.js +++ b/client/coral-framework/constants/auth.js @@ -5,8 +5,8 @@ export const SHOW_SIGNIN_DIALOG = 'SHOW_SIGNIN_DIALOG'; export const HIDE_SIGNIN_DIALOG = 'HIDE_SIGNIN_DIALOG'; export const CREATE_USERNAME_REQUEST = 'CREATE_USERNAME_REQUEST'; -export const CREATEUSERNAME_SUCCESS = 'CREATEUSERNAME_SUCCESS'; -export const CREATEUSERNAME_FAILURE = 'CREATEUSERNAME_FAILURE'; +export const CREATE_USERNAME_SUCCESS = 'CREATE_USERNAME_SUCCESS'; +export const CREATE_USERNAME_FAILURE = 'CREATE_USERNAME_FAILURE'; export const CREATE_USERNAME = 'CREATE_USERNAME'; export const SHOW_CREATEUSERNAME_DIALOG = 'SHOW_CREATEUSERNAME_DIALOG'; export const HIDE_CREATEUSERNAME_DIALOG = 'HIDE_CREATEUSERNAME_DIALOG'; diff --git a/client/coral-framework/reducers/auth.js b/client/coral-framework/reducers/auth.js index 65cd366eb..f9712c937 100644 --- a/client/coral-framework/reducers/auth.js +++ b/client/coral-framework/reducers/auth.js @@ -50,12 +50,12 @@ export default function auth (state = initialState, action) { return state.merge(Map({ showCreateUsernameDialog: false })); - case actions.CREATEUSERNAME_SUCCESS : + case actions.CREATE_USERNAME_SUCCESS : return state.merge(Map({ showCreateUsernameDialog: false, error: '' })); - case actions.CREATEUSERNAME_FAILURE : + case actions.CREATE_USERNAME_FAILURE : return state .set('error', action.error); case actions.CHANGE_VIEW : diff --git a/services/passport.js b/services/passport.js index d265d9812..229541521 100644 --- a/services/passport.js +++ b/services/passport.js @@ -103,8 +103,6 @@ if (process.env.TALK_FACEBOOK_APP_ID && process.env.TALK_FACEBOOK_APP_SECRET && clientSecret: process.env.TALK_FACEBOOK_APP_SECRET, callbackURL: `${process.env.TALK_ROOT_URL}/api/v1/auth/facebook/callback`, - // TODO: remove displayName reference when we have steps in the FE to handle - // the username create flow. profileFields: ['id', 'displayName', 'picture.type(large)'] }, (accessToken, refreshToken, profile, done) => { UsersService diff --git a/services/users.js b/services/users.js index aef30aa75..a319cebe2 100644 --- a/services/users.js +++ b/services/users.js @@ -109,7 +109,7 @@ module.exports = class UsersService { * @param {Object} profile - User social/external profile * @param {Function} done [description] */ - static findOrCreateExternalUser({id, provider, displayname}) { + static findOrCreateExternalUser({id, provider, displayName}) { return UserModel .findOne({ profiles: { @@ -123,8 +123,8 @@ module.exports = class UsersService { if (user) { return user; } - - let username = UsersService.castUsername(displayname); + + let username = UsersService.castUsername(displayName); // The user was not found, lets create them! user = new UserModel({ @@ -220,14 +220,14 @@ module.exports = class UsersService { * @param {String} username name of the display user * @param {Function} done callback */ - static createLocalUser(email, password, username) { + static createLocalUser(email, password, displayname) { if (!email) { return Promise.reject(errors.ErrMissingEmail); } email = email.toLowerCase().trim(); - username = username.trim(); + let username = displayname.trim(); return Promise.all([ UsersService.isValidUsername(username),