mirror of
https://github.com/wassname/talk.git
synced 2026-08-15 12:55:10 +08:00
handle confirmed email better
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import update from 'immutability-helper';
|
||||
import get from 'lodash/get';
|
||||
|
||||
export default {
|
||||
mutations: {
|
||||
UpdateEmailAddress: () => ({
|
||||
updateQueries: {
|
||||
CoralEmbedStream_Profile: previousData => {
|
||||
// Find the local profile (if they have one).
|
||||
const localIndex = get(previousData, 'me.profiles', []).indexOf(
|
||||
({ provider }) => provider === 'local'
|
||||
);
|
||||
if (localIndex < 0) {
|
||||
return previousData;
|
||||
}
|
||||
|
||||
// Mutate the confirmedAt, because we changed the email address, they
|
||||
// can't possibly be confirmed now as well.
|
||||
return update(previousData, {
|
||||
me: {
|
||||
profiles: {
|
||||
[localIndex]: {
|
||||
confirmedAt: {
|
||||
$set: null,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
}),
|
||||
},
|
||||
};
|
||||
@@ -1,6 +1,7 @@
|
||||
import ChangePassword from './containers/ChangePassword';
|
||||
import Profile from './containers/Profile';
|
||||
import translations from './translations.yml';
|
||||
import graphql from './graphql';
|
||||
|
||||
export default {
|
||||
translations,
|
||||
@@ -8,4 +9,5 @@ export default {
|
||||
profileHeader: [Profile],
|
||||
profileSettings: [ChangePassword],
|
||||
},
|
||||
...graphql,
|
||||
};
|
||||
|
||||
@@ -43,6 +43,7 @@ async function updateUserEmailAddress(ctx, email, confirmPassword) {
|
||||
},
|
||||
{
|
||||
$set: { 'profiles.$.id': email },
|
||||
$unset: { 'profiles.$.metadata.confirmed_at': 1 },
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user