Skip to main content

User accounts

This article covers how you create and manage Users in your app

Written by Sofia Maconi

In this article, we'll look at how Bubble handles setting up and managing user accounts.

Technically, users are just another data type in your app's database. But user accounts carry a lot of responsibility, so Bubble treats the User data type a bit differently from the rest:

Feature

What Bubble does

Secure credentials

Passwords are hashed and salted, and user data is encrypted both in transit and at rest.

Signing up and logging in

Creating accounts, logging users in, and remembering them between sessions is handled for you.

Account security features

Email confirmation, password resets, two-factor authentication (2FA), magic login links, and temporary passwords are built in.

Temporary users

Visitors who haven't signed up get a temporary user. Data saved on that user carries over when they sign up, which is useful for things like a shopping cart.

Privacy rules

Privacy rules can compare a record with the current user, so you can control access to data based on who the user is and what's stored on them.

Account security is hard to get right, and it works much the same way across most apps. That's why Bubble takes care of the underlying mechanics: it saves you development time and keeps the security side of user accounts up to date without extra work on your part.

What is a user account?

Most of us have dozens or even hundreds of user accounts: we're logged in to our phones, our email, social media, forums, and even newspapers. We all know what they are, so let's change perspective a bit: why does an app need user accounts?

The first answer is that not every app does. You can build a highly useful app where nobody ever creates an account, even one that lets visitors add and change things in the database. So it's worth separating two ideas: your app can have users, registered users, or both. Every visitor is a user, but only those who sign up become registered users. This article focuses on registered users, meaning users who have signed up with an email and password or through a third-party service.

Registering users serves many purposes:

Purpose

Description

Keeping data private

In many apps, a user should only see their own data, or the data of a select group of other users.

Saving settings

Users can save preferences and profile details that are still there the next time they use the app.

Controlling access

Some apps only let registered users access their pages.

Assigning roles and permissions

Once you can identify each user, you can assign roles that control what they're allowed to see and do.

Personalization

Apps like social networks and e-commerce stores can show each user a personalized stream of content.

Teaming up

Apps where people share data and collaborate need to know who each person is to control who has access to what.

Payment processing

Orders and payment history are usually attached to a permanent user.

Communication

Knowing who your users are lets you reach them in the app or through channels like email.

As you can see, user accounts aren't only about security and privacy. Just like any other data type, you can add as many fields to the User data type as you need. The User type also comes with a few fields of its own to handle the account. These can't be changed or deleted, and they're the same in every Bubble app.

Built-in fields

Like other data types, the User type has a set of built-in fields. On top of those, it comes with three fields of its own:

Field

Visible in the database editor

Description

Email

Yes

The user's email address, used to sign up and log in.

Password

No

The user's password, stored as a secure hash.

Email confirmed

No

A yes/no value that shows whether the user has confirmed their email.

Email

The email field can't be empty on a registered user, and it needs to be a valid email address. Every user in your app needs a unique email address, so two users can't sign up with the same one.

Password

The password field is different from every other field: it's invisible, even to you as the app developer. Bubble stores passwords following industry-standard practices.

How passwords are kept safe

Bubble protects user passwords with two techniques: one-way hashing and salting.

One-way hashing turns the password into a fixed-length code, called a hash. Once a password has been hashed, it can't be turned back into its original form, and the hash is what's stored in the database. When a user logs in, Bubble hashes the password they entered and compares it to the stored hash. If the two match, the user is logged in.

Salting adds a random string of characters to the password before it's hashed. For example, if two users both choose the password "password123", each password gets its own random string, such as "password123" + "pEoW82!", so the two hashes come out completely different. That means an attacker can't use a list of precomputed hashes for common passwords to work out what the original password was.

Bubble only compares hashes and never knows what the original password is. Even if someone gained access to the database, they couldn't see the actual passwords, and not even Bubble can.

One-way hashing combined with salting is widely regarded as standard practice for storing passwords.

Email confirmed

The Email confirmed field is also invisible. It holds a yes/no value that shows whether the user has confirmed their email address. The value changes to yes when the user clicks the link in a confirmation email, sent either by the Send confirmation email action or by the Sign the user up action with Send an email to confirm the email checked.

You can't change this field directly. Only the user can update it, by confirming their email.

Finding the Current User's email confirmed data source in the dynamic expression editor.

Signing up users

This article covers the most common actions for user accounts, but not every one. To see all the actions and operators available for users, check out the references below:

Reference: Account actions
Reference: User operators

Bubble handles the technical side of signing users up, but the design and user experience are entirely up to you.

To sign a user up, you need two pieces of text from them: a valid email address that isn't already in use in your app, and a password. You collect these with input elements and pass them to the Sign the user up action.

Bubble's workflow editor showing the Log the user in action.

The Sign the user up action has these main properties:

Property

Description

Email

The email address the user signs up with.

Password

The password the user chooses.

Require a password confirmation

When checked, the user types their password twice, and the two have to match.

Send an email to confirm the email

When checked, Bubble sends the user a confirmation email right after they sign up.

Change another field

Lets you save other fields on the new user at the same time, such as their name.

Setting up a signup form

1. Add the input elements

Add an input for the email address and one for the password. If you want users to confirm their password, add a second password input.

Set the email input's content format to Email and the password inputs' content format to Password, so the email is validated and the password characters are hidden.

2. Start a workflow

Add a button, such as Sign up, and start a workflow with the An element is clicked event.

3. Add the Sign the user up action

Add the Sign the user up action. Set Email to the email input's value and Password to the password input's value. If you added a second password input, check Require a password confirmation and set Password confirmation to that input's value.

4. Save more information (optional)

If you collect more information at signup, like the user's name, check Change another field and map each field to its input.

5. Send the user onward

Add a Go to page action to take the new user where you want them, such as a dashboard or a welcome page.

Input elements can format what the user types, such as hiding password characters, and can check that the input matches an expected format, such as a valid email address. We recommend using both in your signup and login forms.

Article section: Input elements

The email and password are sent to Bubble's server encrypted, and the password is hashed and salted, so no one can read it, not even the Bubble team.

As soon as the action runs, Bubble creates the account and the user is logged in. The session lasts for 365 days, or until the user logs out or clears the cookies in their browser.

Logging users in

Logging a user in works much like signing them up. The Log the user in action needs two inputs: the email and the password. Bubble sends them to the server encrypted to check the credentials, and if both are correct, the user is logged in.

The Stay logged in property controls how long the session lasts:

Stay logged in

Session length

Checked

365 days

Unchecked

24 hours

A common setup is to add a Remember me checkbox to your login form and use its value for the Stay logged in property, so each user can choose.

Signing up and logging in with a third-party service

Instead of an email and password, you can let users sign up and log in with an account they already have, such as Google, Facebook, LinkedIn, or X (Twitter). This is often called social login, and it works through a standard called OAuth.

What is OAuth?

OAuth is an open standard that lets one app get limited access to a user's account on another service, without ever seeing that user's password.

When a user clicks a button like Log in with Google, they're sent to Google's own login page. After they log in and approve the request, Google sends your app a token that confirms who the user is and grants the access they agreed to. Your app never handles their Google password.

Third-party login has a couple of advantages:

  • Users can sign up in a few clicks and don't need to remember another password.

  • Depending on the service and the permissions the user grants, your app can also fetch data on their behalf, such as their email address or profile picture.

Bubble offers plugins for several services, and you can find more in the plugin marketplace. You can also connect to other providers with the API Connector.

If you need users to log in through their organization's identity provider (IdP), you can set up SSO with the WorkOS plugin or the API Connector.

Example: logging in with Facebook

This example describes how Facebook login works overall. To read more about the Facebook plugin's properties, check out the resources below:

Article: Using the Facebook Graph API plugin


Reference: Facebook

Let's say your app has a button labeled Log in with Facebook.

When you set up this flow, you define the level of authorization your app needs. By default, most services only share the user's public profile and email address, but you can ask for more permissions if your app needs them.

Only ask for the permissions your app actually uses. It's better for your users' privacy and security, and a long list of permission requests can lead to fewer users signing up.

When a user signs up with Facebook, Bubble creates a new user in the database, just like a regular signup with an email and password. The difference is how they log in later. Since they never set a password, they log in with Facebook again. If they're already logged in to Facebook in the same browser, that's usually a single click.

Mixing traditional and social logins

A user can have both a traditional login and one or more social logins. This can play out in a few different ways, which we cover in the article series below:

Article series: OAuth plugins

Temporary users

Signing a user up gives them an email address and a permanent place in your database. In many cases, it's also when they choose a password.

But Bubble starts keeping track of who the user is before that. When someone visits your app for the first time, Bubble saves a cookie in their browser and creates a temporary user. That lets you remember who the user is during their visit and build logic that relies on data stored on the current user, such as:

  • Saving preferences and settings

  • Storing a shopping cart

  • Personalizing the experience

A temporary user stays active on the same device for 72 hours. When the user signs up, Bubble automatically transfers the data stored on the temporary user to their new account.

Because every visitor gets a temporary user, the Current User data source is never empty, as long as cookies are allowed. To check whether a user has actually signed up and logged in, use the is logged in[^6] operator, such as Current User is logged in.

Data stored on a temporary user is transferred automatically when the user signs up, but not when they log in to an existing account.

There's one exception: in the Settings tab, you can stop Bubble from setting cookies on new visitors automatically. If you do, Bubble doesn't create a temporary user until the visitor accepts cookies through the Opt-in to cookies action. Until then, anything stored on the current user is lost when they close the browser tab.

User accounts in native mobile apps

Bubble for native mobile apps uses the same user accounts as your web app within the same project. A user who signs up on the web can log in to your iOS or Android app with the same credentials, and the other way around.

Action

How it works

Sign the user up and Log the user in

Work the same way as in your web app.

Signup/login with a web browser

Only available in native mobile apps. Opens a page from your web app to sign up or log in the user, so you can reuse your existing signup and login page instead of building a separate one for mobile. Supports email and password login, OAuth login, and 2FA.

Bubble's workflow editor showing the Signup/login with a web browser action

Other account actions

Beyond signing up and logging in, Bubble includes actions for most of the account tasks your app is likely to need:

Action

What it does

Send confirmation email

Sends the user an email with a link to confirm their email address.

Send password reset email

Sends the user an email with a link to reset their password. Reset links are valid for 24 hours.

Reset password

Sets a new password for a user who followed a password reset link.

Send magic login link

Sends the user a link that logs them in without a password.

Update the user's credentials

Changes the current user's email or password. Requires their current password.

Assign a temp password to a user

Generates a temporary password for a user. Temporary passwords don't expire automatically.

Create an account for someone else

Creates a new user account without logging anyone in, such as when an admin invites a user.

Log the user out

Logs the current user out.

Log out other user's sessions

Logs the current user out on all other devices.

Opt-in to cookies and Opt-out from cookies

Lets users accept or decline the cookies Bubble sets.

2FA actions

A set of actions for setting up, checking, and disabling two-factor authentication.

Reference: Account actions

FAQ: User accounts

How can I help my users log in if I can't see their password?

It's widely regarded as a basic security practice that no one, not even an app's developer, should have access to a user's password. If a user has lost their password, you can help them reset it or assign them a temporary one.

Can I log users out of sessions on multiple devices?

Yes, with the Log out other user's sessions action. It logs the user out on every device except the one running the action. To log out the current session too, follow it with the Log the user out action.

How long does a user stay logged in?

It depends on the type of user and how they logged in:

Situation

Session length

Temporary user (hasn't signed up)

72 hours on the same device

Logged in with Stay logged in unchecked

24 hours

Logged in with Stay logged in checked

365 days

A user can also be logged out earlier if:

  • The Log the user out action runs

  • The Log out other user's sessions action runs on another device

  • The user clears their browser's cookies

Is there a difference between Make changes to a thing with Current User as the thing, and Make changes to current user?

No. Both let you change any custom field on the user.

Why can't I change the user's email or password with the Make changes to current user action?

The email and password are the user's credentials, so Bubble handles them with a dedicated action: Update the user's credentials. For security reasons, this action requires the user's current password in its Old password property, so you'll need an input element where the user can type it.

How do I check whether a user is logged in?

Use the is logged in operator on the Current User data source, such as Current User is logged in. Checking whether Current User is empty doesn't work, since every visitor has a temporary user.

Can I create an account on behalf of someone else?

Yes, with the Create an account for someone else action. It creates the account without logging anyone in, which is useful when an admin adds users or invites them by email.

Does data on a temporary user carry over when they log in?

No. Data on a temporary user only transfers automatically when the user signs up. If an existing user logs in, data saved on their temporary user isn't moved to their account.

Other ways to learn

Did this answer your question?