Live Chat

We'll need to share your messages (and your email address if you're logged in) with our live chat provider, Drift. Here's their privacy policy.

If you don't want to do this, you can email us instead at contact@anvil.works.

User Management

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:

Get a login form in one line

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.

Building the process yourself

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.

The user account options

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.

How user accounts are 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 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 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.