Skip to content

Commit 3538f9e

Browse files
committed
fixed. Forgot this is an action that's only triggered from admin panel.
1 parent 804b2e0 commit 3538f9e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

server/methods/deleteUser.coffee

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ Meteor.methods
22
deleteUser: (userId) ->
33
if not Meteor.userId()
44
throw new Meteor.Error('invalid-user', "[methods] deleteUser -> Invalid user")
5-
6-
user = Meteor.users.findOne userId
75

6+
user = Meteor.users.findOne Meteor.userId()
87
unless user?.admin is true
98
throw new Meteor.Error 'not-authorized', '[methods] deleteUser -> Not authorized'
109

10+
user = Meteor.users.findOne userId
1111
unless user?
1212
throw new Meteor.Error 'not-found', '[methods] deleteUser -> User not found'
1313

@@ -18,6 +18,10 @@ Meteor.methods
1818
if room.t isnt 'c' and room.usernames.length is 1
1919
ChatRoom.remove subscription.rid # Remove non-channel rooms with only 1 user (the one being deleted)
2020

21+
22+
23+
24+
2125
ChatSubscription.remove { "u._id": userId } # Remove user subscriptions
2226

2327
rooms = ChatRoom.find({ "u._id": userId }).fetch()
@@ -27,4 +31,4 @@ Meteor.methods
2731
ChatRoom.update {}, { $pull: { usernames: user.username } }, { multi: true } # Remove user from all other rooms
2832
Meteor.users.remove { _id: userId } # Remove user from users database
2933

30-
return true
34+
return true

0 commit comments

Comments
 (0)