Skip to content

Commit 8f8101c

Browse files
authored
Merge pull request topcoder-platform#55 from applehit16/email-conflict
show error message when user email is used
2 parents 97ece93 + f20fe12 commit 8f8101c

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

src/actions/profile.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,16 @@ function verifyMemberNewEmailDone(handle, tokenV3, emailVerifyToken) {
434434
.then(res => ({ data: res }));
435435
}
436436

437+
/**
438+
* @static
439+
* @desc Creates an action that toggles isEmailConflict state
440+
* @param {boolean} state
441+
* @return {Action}
442+
*/
443+
function updateEmailConflict(state = false) {
444+
return state;
445+
}
446+
437447
export default createActions({
438448
PROFILE: {
439449
LOAD_PROFILE: loadProfile,
@@ -480,5 +490,6 @@ export default createActions({
480490
UPDATE_PASSWORD_DONE: updatePasswordDone,
481491
VERIFY_MEMBER_NEW_EMAIL_INIT: verifyMemberNewEmailInit,
482492
VERIFY_MEMBER_NEW_EMAIL_DONE: verifyMemberNewEmailDone,
493+
UPDATE_EMAIL_CONFLICT: updateEmailConflict,
483494
},
484495
});

src/reducers/profile.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,14 @@ function onDeletePhotoDone(state, { payload, error }) {
212212
function onUpdateProfileDone(state, { payload, error }) {
213213
const newState = { ...state, updatingProfile: false };
214214

215+
if (payload.isEmailConflict) {
216+
return {
217+
...newState,
218+
isEmailConflict: true,
219+
updateProfileSuccess: false,
220+
};
221+
}
222+
215223
if (error) {
216224
logger.error('Failed to update user profile', payload);
217225
fireErrorMessage('ERROR: Failed to update user profile!');
@@ -455,6 +463,19 @@ function onVerifyMemberNewEmailDone(state, { payload, error }) {
455463
};
456464
}
457465

466+
/**
467+
* Handles UPDATE_EMAIL_CONFLICT action
468+
* @param {Object} state
469+
* @param {Object} action Payload will be a boolean value
470+
* @return {Object} New state
471+
*/
472+
function onUpdateEmailConflict(state, { payload }) {
473+
return {
474+
...state,
475+
isEmailConflict: payload,
476+
};
477+
}
478+
458479
/**
459480
* Creates a new Profile reducer with the specified initial state.
460481
* @param {Object} initialState Optional. Initial state.
@@ -509,6 +530,7 @@ function create(initialState) {
509530
[a.updatePasswordDone]: onUpdatePasswordDone,
510531
[a.verifyMemberNewEmailInit]: state => ({ ...state, verifyingEmail: true }),
511532
[a.verifyMemberNewEmailDone]: onVerifyMemberNewEmailDone,
533+
[a.updateEmailConflict]: onUpdateEmailConflict,
512534
}, _.defaults(initialState, {
513535
achievements: null,
514536
copilot: false,

src/services/members.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ class MembersService {
204204
async updateMemberProfile(profile) {
205205
const url = profile.verifyUrl ? `/members/${profile.handle}?verifyUrl=${profile.verifyUrl}` : `/members/${profile.handle}`;
206206
const res = await this.private.api.putJson(url, { param: profile.verifyUrl ? _.omit(profile, ['verifyUrl']) : profile });
207+
if (profile.verifyUrl && res.status === 409) {
208+
return Promise.resolve(Object.assign({}, profile, { isEmailConflict: true }));
209+
}
207210
return getApiResponsePayload(res);
208211
}
209212

0 commit comments

Comments
 (0)
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