diff options
Diffstat (limited to 'models/users.js')
-rw-r--r-- | models/users.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/models/users.js b/models/users.js index 29504aa8..c2238cde 100644 --- a/models/users.js +++ b/models/users.js @@ -334,6 +334,28 @@ Meteor.methods({ check(limit, Number); Meteor.user().setShowCardsCountAt(limit); }, + setEmail(email) { + check(email, String); + const existingUser = Users.findOne({ 'emails.address': email }, { fields: { _id: 1 } }); + if (existingUser) { + throw new Meteor.Error('email-already-taken'); + } else { + Users.update(this.userId, { + $set: { + emails: [{ + address: email, + verified: false, + }], + }, + }); + } + }, + setUsernameAndEmail(username, email) { + check(username, String); + check(email, String); + Meteor.call('setUsername', username); + Meteor.call('setEmail', email); + }, }); if (Meteor.isServer) { |