From f20fe12b42aa009fb89c7d4d11854160b3b0e227 Mon Sep 17 00:00:00 2001 From: applehit16 Date: Thu, 18 Apr 2019 02:29:56 -0700 Subject: [PATCH] show error message when user email is used --- src/actions/profile.js | 11 +++++++++++ src/reducers/profile.js | 22 ++++++++++++++++++++++ src/services/members.js | 3 +++ 3 files changed, 36 insertions(+) diff --git a/src/actions/profile.js b/src/actions/profile.js index f877b3ab..3996263c 100644 --- a/src/actions/profile.js +++ b/src/actions/profile.js @@ -434,6 +434,16 @@ function verifyMemberNewEmailDone(handle, tokenV3, emailVerifyToken) { .then(res => ({ data: res })); } +/** + * @static + * @desc Creates an action that toggles isEmailConflict state + * @param {boolean} state + * @return {Action} + */ +function updateEmailConflict(state = false) { + return state; +} + export default createActions({ PROFILE: { LOAD_PROFILE: loadProfile, @@ -480,5 +490,6 @@ export default createActions({ UPDATE_PASSWORD_DONE: updatePasswordDone, VERIFY_MEMBER_NEW_EMAIL_INIT: verifyMemberNewEmailInit, VERIFY_MEMBER_NEW_EMAIL_DONE: verifyMemberNewEmailDone, + UPDATE_EMAIL_CONFLICT: updateEmailConflict, }, }); diff --git a/src/reducers/profile.js b/src/reducers/profile.js index c463bf10..1d7711a7 100644 --- a/src/reducers/profile.js +++ b/src/reducers/profile.js @@ -212,6 +212,14 @@ function onDeletePhotoDone(state, { payload, error }) { function onUpdateProfileDone(state, { payload, error }) { const newState = { ...state, updatingProfile: false }; + if (payload.isEmailConflict) { + return { + ...newState, + isEmailConflict: true, + updateProfileSuccess: false, + }; + } + if (error) { logger.error('Failed to update user profile', payload); fireErrorMessage('ERROR: Failed to update user profile!'); @@ -455,6 +463,19 @@ function onVerifyMemberNewEmailDone(state, { payload, error }) { }; } +/** + * Handles UPDATE_EMAIL_CONFLICT action + * @param {Object} state + * @param {Object} action Payload will be a boolean value + * @return {Object} New state + */ +function onUpdateEmailConflict(state, { payload }) { + return { + ...state, + isEmailConflict: payload, + }; +} + /** * Creates a new Profile reducer with the specified initial state. * @param {Object} initialState Optional. Initial state. @@ -509,6 +530,7 @@ function create(initialState) { [a.updatePasswordDone]: onUpdatePasswordDone, [a.verifyMemberNewEmailInit]: state => ({ ...state, verifyingEmail: true }), [a.verifyMemberNewEmailDone]: onVerifyMemberNewEmailDone, + [a.updateEmailConflict]: onUpdateEmailConflict, }, _.defaults(initialState, { achievements: null, copilot: false, diff --git a/src/services/members.js b/src/services/members.js index 84b97f56..62afbf36 100644 --- a/src/services/members.js +++ b/src/services/members.js @@ -204,6 +204,9 @@ class MembersService { async updateMemberProfile(profile) { const url = profile.verifyUrl ? `/members/${profile.handle}?verifyUrl=${profile.verifyUrl}` : `/members/${profile.handle}`; const res = await this.private.api.putJson(url, { param: profile.verifyUrl ? _.omit(profile, ['verifyUrl']) : profile }); + if (profile.verifyUrl && res.status === 409) { + return Promise.resolve(Object.assign({}, profile, { isEmailConflict: true })); + } return getApiResponsePayload(res); } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy