{"action":"created","issue":{"url":"https://api.github.com/repos/meteor/meteor/issues/5110","labels_url":"https://api.github.com/repos/meteor/meteor/issues/5110/labels{/name}","comments_url":"https://api.github.com/repos/meteor/meteor/issues/5110/comments","events_url":"https://api.github.com/repos/meteor/meteor/issues/5110/events","html_url":"https://github.com/meteor/meteor/issues/5110","id":105070556,"number":5110,"title":"Can't prevent creation of new password user without causing error message","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":[{"url":"https://api.github.com/repos/meteor/meteor/labels/feature","name":"feature","color":"02d7e1"},{"url":"https://api.github.com/repos/meteor/meteor/labels/Project:Accounts%20(in%20user%20apps)","name":"Project:Accounts (in user apps)","color":"eb6420"},{"url":"https://api.github.com/repos/meteor/meteor/labels/Project:Accounts:UI","name":"Project:Accounts:UI","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-06T04:34:18Z","updated_at":"2015-09-08T23:30:45Z","closed_at":null,"body":"If a `validateLoginAttempt()` handler throws a `LoginCancelledError`, during a call to `Accounts.createUser()`, `accounts-ui-unstyled` will display the reason as an error message. By contrast, if the same error is thrown while logging in using an OAuth service, it is ignored. It should be ignored in the `Accounts.createUser()` case as well (or the reason should be displayed as an info message instead of an error). Alternatively, there should be some other way for the server to indicate that a new user wasn't created without causing an error to be displayed. `useraccounts:core` uses the `LoginCancelledError` to avoid an error message when adding an OAuth service to an existing account, and `brettle:accounts-add-service` does the same and can be used when adding a password login. It would be nice if it could use the same mechanism. \r\n\r\nI'm willing to create a PR that addresses this (and adds tests for it) if such a PR would be considered."},"comment":{"url":"https://api.github.com/repos/meteor/meteor/issues/comments/138730688","html_url":"https://github.com/meteor/meteor/issues/5110#issuecomment-138730688","issue_url":"https://api.github.com/repos/meteor/meteor/issues/5110","id":138730688,"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},"created_at":"2015-09-08T23:30:45Z","updated_at":"2015-09-08T23:30:45Z","body":"Sorry for the poor explanation. Let me try again... \r\n\r\nThe situation is a guest user (e.g. created via my `brettle:accounts-anonymous` package) adding a login service to his account. My `brettle:accounts-patch-ui` package overrides `currentUser` so that `accounts-ui-unstyled` treats guests as logged out (i.e. it lets the guest user sign-in with any of the available login services). When the guest user signs-in with one of the login services, my `brettle:accounts-add-service` package detects that the user is already logged in (as a guest in this case) and is logging in as a new user using a new service. It interprets this as a desire to add the new service to the current user's account. It adds the service to the current user's account and throws a `LoginCancelledError` from a `validateLoginAttempt()` handler. This prevents the creation of the new user and keeps the user logged in to their existing account. When the new service is an OAuth service, this works great from a UI perspective. When the new service is the password service, the error is displayed.\r\n\r\nI understand that this isn't the original purpose of `LoginCancelledError` and am open to suggestions for better ways to achieve the desired effect. Specifically, my goals are that the user's id should not change, no new account should be created, and it should work with arbitrary login services. \r\n\r\nThe simplest solution seems to be to expand the meaning of `LoginCancelledError` to include any cancellation by the server that can be ignored by the user (i.e. a cancellation that was initiated by the user, or a cancellation that was initiated by the server but doesn't affect the user). With that new interpretation of `LoginCancelledError`, `accounts-ui-unstyled` would need small changes to treat `LoginCancelledError` the same as success when it calls `Accounts.createUser()` [here](https://github.com/meteor/meteor/blob/devel/packages/accounts-ui-unstyled/login_buttons_dropdown.js#L432), and possibly `Meteor.loginWithPassword()` [here](https://github.com/meteor/meteor/blob/devel/packages/accounts-ui-unstyled/login_buttons_dropdown.js#L392).\r\n\r\n\r\n\r\n"}}