Skip to content

Commit

Permalink
Fixes an error triggered by the new users login in using CAS trying t…
Browse files Browse the repository at this point in the history
…o subscribe to general channel twice (#11257)
  • Loading branch information
Hudell authored and rodrigok committed Jun 26, 2018
1 parent de52e22 commit 79b381b
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions packages/rocketchat-cas/server/cas_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,18 @@ Accounts.registerLoginHandler(function(options) {
if (!room) {
room = RocketChat.models.Rooms.createWithIdTypeAndName(Random.id(), 'c', room_name);
}
RocketChat.models.Rooms.addUsernameByName(room_name, result.username);
RocketChat.models.Subscriptions.createWithRoomAndUser(room, user, {
ts: new Date(),
open: true,
alert: true,
unread: 1,
userMentions: 1,
groupMentions: 0
});

if (!RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(room._id, userId)) {
RocketChat.models.Rooms.addUsernameByName(room_name, result.username);
RocketChat.models.Subscriptions.createWithRoomAndUser(room, user, {
ts: new Date(),
open: true,
alert: true,
unread: 1,
userMentions: 1,
groupMentions: 0
});
}
}
});
}
Expand Down

0 comments on commit 79b381b

Please sign in to comment.