mirror of
https://github.com/wassname/talk.git
synced 2026-07-04 08:12:37 +08:00
Fixed email in use error
This commit is contained in:
@@ -35,16 +35,24 @@ async function updateUserEmailAddress(ctx, email, confirmPassword) {
|
||||
email = email.toLowerCase().trim();
|
||||
|
||||
// Update the Users email address.
|
||||
await User.update(
|
||||
{
|
||||
id: user.id,
|
||||
profiles: { $elemMatch: { provider: 'local' } },
|
||||
},
|
||||
{
|
||||
$set: { 'profiles.$.id': email },
|
||||
$unset: { 'profiles.$.metadata.confirmed_at': 1 },
|
||||
try {
|
||||
await User.update(
|
||||
{
|
||||
id: user.id,
|
||||
profiles: { $elemMatch: { provider: 'local' } },
|
||||
},
|
||||
{
|
||||
$set: { 'profiles.$.id': email },
|
||||
$unset: { 'profiles.$.metadata.confirmed_at': 1 },
|
||||
}
|
||||
);
|
||||
} catch (err) {
|
||||
if (err.code === 11000) {
|
||||
throw new ErrEmailTaken();
|
||||
}
|
||||
);
|
||||
|
||||
throw err;
|
||||
}
|
||||
|
||||
// Get some context for the email to be sent.
|
||||
const { organizationContactEmail } = await Settings.load([
|
||||
|
||||
Reference in New Issue
Block a user