User Management
The Users Service handles signup, login and user permissions, and provides a range of functionality to make user management easy and flexible. See the Quickstart for logins and the Quickstart for permissions to get up and running quickly.
To add the Users Service to your app, click the blue plus button in the Sidebar Menu. Then select the Users service .
To add user management to your app, you must first enable the Users Service in the App Browser:
Get a login form in one line
You can present a signup/login form with a single line of code. This handles signup, login, email verification, password reset and ‘remember me’. See Presenting a Login Form for details.
Building the process yourself
If you want to build your own login form or customise your signup/login workflow, see our how-to guide.
There are also a number of functions such as anvil.users.logout()
that let you run the steps of the user management process manually.
See Logging in Using Code or the API Reference to learn what functions are available.
Authentication Options
In addition to username and password, you can allow your users to log in with their existing Google, Facebook or Microsoft accounts. Anvil also has built-in local Active Directory (AD) and PKI Certificate systems for Enterprise users, and supports SAML Authentication. See Authentication Choices for more information.
Anvil’s Users Service also comes with Two-Factor Authentication. See Two-Factor Authentication for more detail.
How user information is stored
If you’re using the Users Service, user accounts are stored in a Data Table called ‘Users’. The password is bcrypt
hashed
for you and the rest of the relevant user details are processed and added to the ‘Users’ Data Table. See the Users Table for more information.
You can add your own columns to this Data Table - it’s common to add a role
column to store user roles for permissions
management.
Checking user permissions
You can get the currently logged-in user using anvil.users.get_user()
. This returns a row from the Users table.
This allows you to set up Python code in your Server Modules that checks usernames or roles before running particular code or returning particular data. This is Anvil’s authorisation model. See User Permissions for more detail.
Do you still have questions?
Our Community Forum is full of helpful information and Anvil experts.