Skip to content

Commit

Permalink
Add loginVisitors callback
Browse files Browse the repository at this point in the history
  • Loading branch information
leoc committed Feb 19, 2015
1 parent 675d774 commit 54b0e72
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions accounts-guest-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,26 @@ if (Package.blaze) {

//no non-logged in users
/* you might need to limit this to avoid flooding the user db */
Meteor.loginVisitor = function (email) {
Meteor.loginVisitor = function (email, callback) {
AccountsGuest.forced = true;
if (!Meteor.userId()) {
Meteor.call('createGuest', email, function (error, result) {
if (error) {
console.log('Error in creating Guest ' + error);
return false;
return callback && callback(error);
}

/* if a simple "true" is returned, we are in a disabled mode */
if(result === true) {
return true;
}
if(result === true) return callback && callback();

Meteor.loginWithPassword(result.email, result.password, function(error) {
if(error) {
console.log('Error logging in ' + error);
return false;
callback && callback(error);
} else {
callback && callback();
}
});
return true;
});
}
}
Expand Down

0 comments on commit 54b0e72

Please sign in to comment.