Skip to content
Snippets Groups Projects
Commit f17ea174 authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Replace all Meteor.users.remove

parent 3c673770
No related branches found
No related tags found
No related merge requests found
...@@ -183,3 +183,17 @@ RocketChat.models.Users = new class asd extends RocketChat.models._Base ...@@ -183,3 +183,17 @@ RocketChat.models.Users = new class asd extends RocketChat.models._Base
_.extend user, data _.extend user, data
return @insert user return @insert user
# REMOVE
removeById: (_id) ->
return @remove _id
removeByUnverifiedEmail: (email) ->
query =
emails:
$elemMatch:
address: email
verified: false
return @remove query
...@@ -19,7 +19,7 @@ Accounts.updateOrCreateUserFromExternalService = (serviceName, serviceData, opti ...@@ -19,7 +19,7 @@ Accounts.updateOrCreateUserFromExternalService = (serviceName, serviceData, opti
if serviceData.email if serviceData.email
# Remove not verified users that have same email # Remove not verified users that have same email
notVerifiedUser = Meteor.users.remove({emails: {$elemMatch: {address: serviceData.email, verified: false}}}) RocketChat.models.Users.removeByUnverifiedEmail serviceData.email
# Try to get existent user with same email verified # Try to get existent user with same email verified
user = RocketChat.models.Users.findOneByVerifiedEmailAddress(serviceData.email, true) user = RocketChat.models.Users.findOneByVerifiedEmailAddress(serviceData.email, true)
......
...@@ -27,6 +27,6 @@ Meteor.methods ...@@ -27,6 +27,6 @@ Meteor.methods
ChatRoom.remove { t: 'd', usernames: user.username } # Remove direct rooms with the user ChatRoom.remove { t: 'd', usernames: user.username } # Remove direct rooms with the user
ChatRoom.update {}, { $pull: { usernames: user.username } }, { multi: true } # Remove user from all other rooms ChatRoom.update {}, { $pull: { usernames: user.username } }, { multi: true } # Remove user from all other rooms
Meteor.users.remove { _id: userId } # Remove user from users database RocketChat.models.Users.removeById userId # Remove user from users database
return true return true
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment