Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for login hooks #7

Open
BudgieInWA opened this issue May 9, 2016 · 2 comments
Open

Support for login hooks #7

BudgieInWA opened this issue May 9, 2016 · 2 comments

Comments

@BudgieInWA
Copy link

I would love to be able to add a server side hook for logging in. Ideally it would be able to modify the user doc that gets created for the new user.

My use case is to generate a random nickname for each anonymous user.

@bastiW
Copy link

bastiW commented May 16, 2016

have not tested yet. But what about using
https://atmospherejs.com/brettle/accounts-login-st

It should work with the LoginState.addSignedUpInterceptor

@BudgieInWA
Copy link
Author

I found Accounts.onCreateUser which is almost exactly what I want:

Accounts.onCreateUser(function(options, user) {
    if (!user.services) {
        user.displayName = "Guest X";
    }
});

I am not using options.anonymous to determine if the user is created by your package, because the documentation for Accounts.onCreateUser warns that options can come from the client and shouldn't be trusted. Perhaps the package should add something to the user doc to securely indicate that the account is an anonymous account. Alternatively, it could provide a AccountsAnonymous.onCreateUser hook which only runs for anonymous accounts.

Then again, I might be giving too much weight to my use case and the current behaviour might be sufficient. In that case, an example like mine in the README might be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants