{"action":"created","issue":{"url":"https://api.github.com/repos/meteor-useraccounts/core/issues/499","labels_url":"https://api.github.com/repos/meteor-useraccounts/core/issues/499/labels{/name}","comments_url":"https://api.github.com/repos/meteor-useraccounts/core/issues/499/comments","events_url":"https://api.github.com/repos/meteor-useraccounts/core/issues/499/events","html_url":"https://github.com/meteor-useraccounts/core/issues/499","id":99917604,"number":499,"title":"Feature Design: Support for guest/anonymous accounts","user":{"login":"brettle","id":118192,"avatar_url":"https://avatars.githubusercontent.com/u/118192?v=3","gravatar_id":"","url":"https://api.github.com/users/brettle","html_url":"https://github.com/brettle","followers_url":"https://api.github.com/users/brettle/followers","following_url":"https://api.github.com/users/brettle/following{/other_user}","gists_url":"https://api.github.com/users/brettle/gists{/gist_id}","starred_url":"https://api.github.com/users/brettle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brettle/subscriptions","organizations_url":"https://api.github.com/users/brettle/orgs","repos_url":"https://api.github.com/users/brettle/repos","events_url":"https://api.github.com/users/brettle/events{/privacy}","received_events_url":"https://api.github.com/users/brettle/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-09T18:14:20Z","updated_at":"2015-08-23T20:37:46Z","closed_at":"2015-08-14T09:03:15Z","body":"I know that @splendido is working on support for guest accounts for 2.0, but I was wondering if a PR that adds such support would be considered. My thinking is to add a `signedInUserId` configuration option whose value is a function that returns the `_id` of the user who is currently \"signed in\". To support anonymous/guest accounts, this could return null for such users. The core code would be changed to use `signedInUserId()` is places where it uses `Meteor.userId()` or `Meteor.user()` to determine whether the current user is signed in.\r\n\r\nDoes this make sense? If so, what should the default be for `signedInUserId`? A couple options:\r\n\r\nOption 1:\r\n```javascript\r\nfunction () { return Meteor.userId(); }\r\n```\r\n\r\nOptions 2:\r\n```javascript\r\nfunction () {\r\n  var user = Meteor.user();\r\n  if (! user) {\r\n    return null;\r\n  }\r\n  // If the user has a username, a profile.name, or at least one email address,\r\n  // then they aren't anonymous, so return them.\r\n  if (typeof(user.username) === 'string'\r\n      || user.profile && typeof(user.profile.name) === 'string'\r\n      || (user.emails && user.emails.length > 0\r\n          && typeof(user.emails[0].address) === 'string')) {\r\n    return user._id;\r\n  }\r\n  // The user is anonymous, so return null\r\n  return null;\r\n}\r\n```\r\nI could live with either, but would prefer Option 2 because it would mean [my accounts-anonymous package](https://github.com/brettle/meteor-accounts-anonymous) would work without needing to override the default.\r\n\r\nThoughts?\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/meteor-useraccounts/core/issues/comments/133928060","html_url":"https://github.com/meteor-useraccounts/core/issues/499#issuecomment-133928060","issue_url":"https://api.github.com/repos/meteor-useraccounts/core/issues/499","id":133928060,"user":{"login":"splendido","id":6148980,"avatar_url":"https://avatars.githubusercontent.com/u/6148980?v=3","gravatar_id":"","url":"https://api.github.com/users/splendido","html_url":"https://github.com/splendido","followers_url":"https://api.github.com/users/splendido/followers","following_url":"https://api.github.com/users/splendido/following{/other_user}","gists_url":"https://api.github.com/users/splendido/gists{/gist_id}","starred_url":"https://api.github.com/users/splendido/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/splendido/subscriptions","organizations_url":"https://api.github.com/users/splendido/orgs","repos_url":"https://api.github.com/users/splendido/repos","events_url":"https://api.github.com/users/splendido/events{/privacy}","received_events_url":"https://api.github.com/users/splendido/received_events","type":"User","site_admin":false},"created_at":"2015-08-23T20:37:46Z","updated_at":"2015-08-23T20:37:46Z","body":"Ok, I'll have a look at it when I'll come to this again.\r\n\r\nTnx!"}}