Handling User Signups for Multi-Tenant SaaS Apps in Bubble

Building a multi-tenant SaaS app in Bubble.io comes with unique challenges, especially when it comes to user management.

Nov 5, 2024

Handling multiuser tenant registered and email addresses across all tenants.

Building a multi-tenant SaaS app in Bubble.io comes with unique challenges, especially when it comes to user management. Two critical considerations for developers are:

  1. Data Separation (Siloing): Ensuring that each tenant’s data is securely separated to maintain privacy and security.

  2. Unique User Signups Across Tenants: Enabling a single end-user to sign up with the same email address across multiple tenants.

In this blog post, we’ll focus on the second challenge: how to enable a single user to sign up with the same email address for multiple tenants in your SaaS app, overcoming Bubble’s built-in unique email validation.

The Problem

Bubble.io requires that email addresses in the Users table be unique. This creates a limitation for multi-tenant SaaS apps:

If a user tries to sign up with the same email address (e.g., username@domain.com) for multiple tenants, Bubble’s validation rules will reject the sign-up.

Why might this happen? Well, let's say you build an auction platform where bidders buy from many different auctioneers all using the platform, then you need to enable users to register independently for each one.

The Solution: Modifying the Email Address

The key to solving this issue is to append a unique identifier to the email address before saving it in Bubble’s database. This makes each email unique for Bubble while preserving the user’s original email for communications.

Here’s how you can implement this solution:

Step-by-Step Guide

  1. User Enters Their Email
    When a user signs up, they provide their email address (e.g., username@domain.com).

  2. Generate a Unique Suffix
    Create a unique identifier for the tenant, such as the tenant's ID, subdomain, or a random string. For example, if the tenant’s ID is tenant123, the suffix will be tenant123.

  3. Modify the Email Address
    Append the unique suffix to the email address, using a format like tenantID+username@domain.com. For example:

  4. Save the Modified Email
    Store the modified email in Bubble’s database. Since the email is now unique for each tenant, it won’t conflict with Bubble’s validation rules.

  5. Retrieve the Original Email When Needed
    Whenever you need the user’s original email address for communications or other tasks,

  6. the stored email at the + symbol and use the first part. For example, from tenant123+username@domain.com, extract username@domain.com.

Why This Works

This approach allows a single user to sign up with the same email address for multiple tenants, while maintaining the following benefits:

  • Bubble’s Validation is Satisfied: The modified email ensures uniqueness in the Users table.

  • Original Email is Preserved: The original email is easily retrievable for communication purposes, ensuring consistency for the end-user.

  • Tenant-Specific Signups: Each tenant can have their own version of the user, linked through the modified email.

Example Use Case

Let’s say you’re building a project management SaaS app. A freelance designer (username@domain.com) works with two different clients using your platform. With this solution:

  1. The designer signs up for Client A (Tenant ID: clientA) with the modified email clientA+username@domain.com.

  2. They also sign up for Client B (Tenant ID: clientB) with the modified email clientB+username@domain.com.

  3. Both clients can interact with the designer’s account independently, while the designer receives consistent communications via username@domain.com.

Final Thoughts

Handling multi-tenant user signups in Bubble can be challenging, but with this email modification technique, you can ensure a seamless experience for both users and tenants, just by appending unique identifiers to email addresses.

Key Benefits:

  • Scales effortlessly across multiple clients (tenants).

  • Maintains security and data separation.

  • Preserves the original email address for consistent user communication.

Ready to build a scalable SaaS app with Bubble? Connect with me to learn more tips, tricks, and best practices for taking your Bubble project to the next level!

Orzo Blue


Bringing your ideas to life

Location

Brighton, United Kingdom

Telephone

+44 (0) 1273 921909