You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/multi-tenant/README.md
+17-11Lines changed: 17 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,11 +10,17 @@ To spin up this example locally, follow these steps:
10
10
11
11
-`npx create-payload-app --example multi-tenant`
12
12
13
-
2.`pnpm dev`, `yarn dev` or `npm run dev` to start the server
13
+
2.`cp .env.example .env` to copy the example environment variables
14
+
15
+
3.`pnpm dev`, `yarn dev` or `npm run dev` to start the server
14
16
- Press `y` when prompted to seed the database
15
-
3.`open http://localhost:3000` to access the home page
16
-
4.`open http://localhost:3000/admin` to access the admin panel
17
-
- Login with email `demo@payloadcms.com` and password `demo`
17
+
4.`open http://localhost:3000` to access the home page
18
+
5.`open http://localhost:3000/admin` to access the admin panel
19
+
20
+
### Default users
21
+
22
+
The seed script seeds 3 tenants.
23
+
Login with email `demo@payloadcms.com` and password `demo`
18
24
19
25
## How it works
20
26
@@ -28,7 +34,7 @@ See the [Collections](https://payloadcms.com/docs/configuration/collections) doc
28
34
29
35
-#### Users
30
36
31
-
The `users` collection is auth-enabled and encompass both app-wide and tenant-scoped users based on the value of their `roles` and `tenants` fields. Users with the role `super-admin` can manage your entire application, while users with the _tenant role_ of `admin` have limited access to the platform and can manage only the tenant(s) they are assigned to, see [Tenants](#tenants) for more details.
37
+
The `users` collection is auth-enabled and encompasses both app-wide and tenant-scoped users based on the value of their `roles` and `tenants` fields. Users with the role `super-admin` can manage your entire application, while users with the _tenant role_ of `admin` have limited access to the platform and can manage only the tenant(s) they are assigned to, see [Tenants](#tenants) for more details.
32
38
33
39
For additional help with authentication, see the official [Auth Example](https://github.com/payloadcms/payload/tree/main/examples/cms#readme) or the [Authentication](https://payloadcms.com/docs/authentication/overview#authentication-overview) docs.
34
40
@@ -40,21 +46,21 @@ See the [Collections](https://payloadcms.com/docs/configuration/collections) doc
40
46
41
47
**Domain-based Tenant Setting**:
42
48
43
-
This example also supports domain-based tenant selection, where tenants can be associated with a specific domain. If a tenant is associated with a domain (e.g., `gold.localhost.com:3000`), when a user logs in from that domain, they will be automatically scoped to the matching tenant. This is accomplished through an optional `afterLogin` hook that sets a `payload-tenant` cookie based on the domain.
49
+
This example also supports domain-based tenant selection, where tenants can be associated with a specific domain. If a tenant is associated with a domain (e.g., `gold.test:3000`), when a user logs in from that domain, they will be automatically scoped to the matching tenant. This is accomplished through an optional `afterLogin` hook that sets a `payload-tenant` cookie based on the domain.
44
50
45
-
The seed script seeds 3 tenants, for the domain portion of the example to function properly you will need to add the following entries to your systems`/etc/hosts` file:
51
+
For the domain portion of the example to function properly, you will need to add the following entries to your system's`/etc/hosts` file:
46
52
47
-
- gold.localhost.com:3000
48
-
-silver.localhost.com:3000
49
-
- bronze.localhost.com:3000
53
+
```
54
+
127.0.0.1 gold.test silver.test bronze.test
55
+
```
50
56
51
57
-#### Pages
52
58
53
59
Each page is assigned a `tenant`, which is used to control access and scope API requests. Only users with the `super-admin` role can create pages, and pages are assigned to specific tenants. Other users can view only the pages assigned to the tenant they are associated with.
54
60
55
61
## Access control
56
62
57
-
Basic role-based access control is setup to determine what users can and cannot do based on their roles, which are:
63
+
Basic role-based access control is set up to determine what users can and cannot do based on their roles, which are:
58
64
59
65
-`super-admin`: They can access the Payload admin panel to manage your multi-tenant application. They can see all tenants and make all operations.
60
66
-`user`: They can only access the Payload admin panel if they are a tenant-admin, in which case they have a limited access to operations based on their tenant (see below).
0 commit comments