forked from artwells/meteor-accounts-guest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccounts-guest-client.js
More file actions
35 lines (33 loc) · 885 Bytes
/
Copy pathaccounts-guest-client.js
File metadata and controls
35 lines (33 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*****************
* special anonymous behavior so that visitors can
* manipulate their work
*
*/
Meteor.loginVisitor = function (email, callback) {
if (!Meteor.userId()) {
Accounts.callLoginMethod({
methodArguments: [{
email: email,
createGuest: true
}],
userCallback: function (error, result) {
if(error) {
callback && callback(error);
} else {
callback && callback();
}
}
});
}
}
//no non-logged in users
/* you might need to limit this to avoid flooding the user db */
Meteor.startup(function(){
Deps.autorun(function () {
if (!Meteor.userId()) {
if (AccountsGuest.forced === true) {
Meteor.loginVisitor();
}
}
});
});