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: docs/guides/authentication/auth0.md
+12-13Lines changed: 12 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,15 +7,15 @@ sidebar_label: 🚧 Auth0
7
7
# Integrating With Auth0
8
8
9
9
10
-
This guide aims to give some simple examples of using Auth0 to provide authentication when used in conjunction with Zenstack. It will not take into account the different types of authentication that Auth0 offers. The premise is that you have and understanding of Auth0's method of authentication and are able to produce an object as a result of authenticating a user with Auth0.
10
+
This guide aims to give some simple examples of using Auth0 to provide authentication when used in conjunction with ZenStack. It will not take into account the different types of authentication that Auth0 offers. The premise is that you have and understanding of Auth0's method of authentication and are able to produce an object as a result of authenticating a user with Auth0.
11
11
12
12
## Enhancing the prisma client
13
13
14
-
The basic premise of applying a custom session object to Zenstack.
14
+
The basic premise of applying a custom session object to ZenStack.
15
15
16
16
Create a user object and provide it to the enhance function when creating the Prisma client.
@@ -84,12 +83,12 @@ You may want to keep a record of User's in your own database.
84
83
85
84
You can create your application in such a way that a lack of the user existing in the managed database triggers a process to create one, such as a user onboarding flow.
86
85
87
-
```
86
+
```ts
88
87
const currentUser =async (req) => {
89
88
const session =awaitgetSession(req); // get your auth0 auth session
90
89
91
90
if (!session?.user.sub) {
92
-
throw new Error('UNAUTHENTICATED'); // Throw an error if the user isn's authenticated
91
+
thrownewError('UNAUTHENTICATED'); // Throw an error if the user isn't authenticated
93
92
}
94
93
95
94
const dbUser =awaitprisma.user.findUnique({ // Find the user in the db
0 commit comments