Skip to content

Conversation

@Custard7
Copy link
Collaborator

@Custard7 Custard7 commented May 1, 2024

Seed

Use seed script to add super admin users to your dev environment. Set PAYLOAD_SEED = true env, and uncomment the seed script line in server.ts.

This seed creates a super-admin user with email admin@welibrary.io and password admin along with the following tenants:

  • ABC
    • Domains:
      • abc.localhost.com:3000
    • Users:
      • admin@abc.com with role admin and password test
      • user@abc.com with role user and password test
    • Pages:
      • ABC Home with content Hello, ABC!
  • BBC
    • Domains:
      • bbc.localhost.com:3000
    • Users:
      • admin@bbc.com with role admin and password test
      • user@bbc.com with role user and password test
    • Pages:
      • BBC Home with content Hello, BBC!

Super Admin can see everything. Admins can only see their tenant data. Users can't login to the dashboard.

NOTICE: seeding the database is destructive because it drops your current database to populate a fresh one from the seed template. Only run this command if you are starting a new project or can afford to lose your current data.

Hosts file

To fully experience the multi-tenancy of this example locally, your app must run on one of the domains listed in any of your tenant's domains field. The simplest way to do this to add the following lines to your hosts file.

# these domains were provided in the seed script
# if needed, change them based on your own tenant settings
# remember to specify the port number when browsing to these domains
127.0.0.1 abc.localhost.com
127.0.0.1 bbc.localhost.com

On Mac you can find the hosts file at /etc/hosts. On Windows, it's at C:\Windows\System32\drivers\etc\hosts.

Then you can access your app at http://abc.localhost.com:3000 and http://bbc.localhost.com:3000. Access control will be scoped to the correct tenant based on that user's tenants

@Custard7 Custard7 changed the base branch from main to payload-2.0 May 1, 2024 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants