User signup, login and permissions checking is something that most apps need. Anvil has a range of functionality to make it easy and flexible.
To do most things in this section, you must first enable the Users Service in the App Browser:
You can present a signup/login form with a single line of code. That handles signup, login, email verification, password reset and ‘remember me’. See Presenting a Login Form for details.
If you want to build your own login form or customise your signup/login workflow, see this post.
There are also a number of functions such as
anvil.users.log_out() that let you run the steps of the user management process manually.
See Logging in Using Code to learn what functions are available.
In addition to username and password, you can enable 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. See Authentication Choices.
If you’re using the Users Service, user accounts are stored in a Data Table called Users. The password is
for you and the rest of the relevant user details are managed automatically too. Read the Users Table.
You can add your own columns to this table - it’s common to add a
role column to store user roles for 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.