From 4f6b9d50b860b3405983bc0da39a9f876e9d1535 Mon Sep 17 00:00:00 2001 From: avataw Date: Sat, 21 May 2022 00:03:16 +0200 Subject: [PATCH 1/2] Add warning box for missing roles in authorization doc --- docs/docs/tutorial/chapter4/authentication.md | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/docs/tutorial/chapter4/authentication.md b/docs/docs/tutorial/chapter4/authentication.md index 5018a194c4b1..05fd381c429d 100644 --- a/docs/docs/tutorial/chapter4/authentication.md +++ b/docs/docs/tutorial/chapter4/authentication.md @@ -774,6 +774,16 @@ export const requireAuth = ({ roles }) => { } ``` +:::caution + +At this point of the tutorial we have **not added roles** to our user model yet, therefore you can ignore the `hasRole` method in `api/src/lib/auth.js` for now. + +If this bothers you, feel free to peek into [the tutorial chapter about Authorization](../chapter7/rbac.md) and add the missing field as described there. +::: + + + + @@ -840,9 +850,22 @@ export const requireAuth = ({ roles }: { roles?: AllowedRoles } = {}) => { } ``` +:::caution + +At this point of the tutorial we have **not added roles** to our user model yet, therefore you can ignore the following error: + +`Property 'roles' does not exist on type '{ id: number; email: string; }'.` + +in the `hasRole` method in `api/src/lib/auth.ts` for now. + +If this bothers you, feel free to peek into [the tutorial chapter about Authorization](../chapter7/rbac.md) and add the missing field as described there. +::: + + + The `getCurrentUser()` function is where the magic happens: whatever is returned by this function is the content of `currentUser`, in both the web and api sides! In the case of dbAuth, the single argument passed in, `session`, contains the `id` of the user that's logged in. It then looks up the user in the database with Prisma, selecting just the `id`. Let's add `email` to this list: From dc5d0a73013cd9e3b5079a959f4c854c2f4829d9 Mon Sep 17 00:00:00 2001 From: Andre Wruszczak Date: Thu, 2 Jun 2022 19:07:50 +0200 Subject: [PATCH 2/2] Update docs/docs/tutorial/chapter4/authentication.md Co-authored-by: Peter Colapietro --- docs/docs/tutorial/chapter4/authentication.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/tutorial/chapter4/authentication.md b/docs/docs/tutorial/chapter4/authentication.md index 05fd381c429d..29357b78251e 100644 --- a/docs/docs/tutorial/chapter4/authentication.md +++ b/docs/docs/tutorial/chapter4/authentication.md @@ -852,7 +852,7 @@ export const requireAuth = ({ roles }: { roles?: AllowedRoles } = {}) => { :::caution -At this point of the tutorial we have **not added roles** to our user model yet, therefore you can ignore the following error: +At this point of the tutorial we have **not added roles** to our user model yet, therefore you can ignore the following error: `Property 'roles' does not exist on type '{ id: number; email: string; }'.`