Skip to content

Commit

Permalink
Fixed Anonymous Registration (#12633)
Browse files Browse the repository at this point in the history
Fix for #8982
  • Loading branch information
wreiske authored and rodrigok committed Nov 21, 2018
1 parent 8744bd3 commit 2882438
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/rocketchat-ui-message/client/messageBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,9 @@ Template.messageBox.events({
'click .register-anonymous'(event) {
event.stopPropagation();
event.preventDefault();
return Meteor.call('registerUser', {}, function(error, loginData) {
if (loginData && loginData.token) {
return Meteor.loginWithToken(loginData.token);
return Meteor.call('registerUser', {}, function(error, result) {
if (!error) {
Meteor.loginWithToken(result.token);
}
});
},
Expand Down
5 changes: 3 additions & 2 deletions server/methods/registerUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ Meteor.methods({
],
});

const { id, token } = Accounts._loginUser(this, userId);
const stampedLoginToken = Accounts._generateStampedLoginToken();

return { id, token };
Accounts._insertLoginToken(userId, stampedLoginToken);
return stampedLoginToken;
} else {
check(formData, Match.ObjectIncluding({
email: String,
Expand Down

0 comments on commit 2882438

Please sign in to comment.