Accounts let users log on a meteor app. This example shows how to let users log with passwords.
The Accounts example code is on github, to get it run:
Add these packages to the meteor app:
For the bootstrap version of accounts, add these packages:
The login buttons can added anywhere in the templates:
Use ‘#if currentUser’ and ‘#unless currentUser’ to detect if the user logged on.
The user is identified by a userid: Meteor.userId()
Users can be logged on several devices, there is a function to log off all other clients: Meteor.logoutOtherClients()
User data is updated with Meteor.user.update(), for example:
Users are deleted with the function remove:
A function can be called when new user are created:
To get the number of accounts use:
To create new accounts from the code, use Accounts.createUser():
Accounts.config holds the global accounts options. We can enable/disable account creation, force email verification and number of days until the user must log on again. Accounts.ui.config holds the options for the ui. With passwordSignupFields, we choose which to display in the accounts ui: only username or username and email.