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
To protect a route, simply use the authentication middleware:
30
+
30
31
```ts
31
32
import { middleware } from'./kernel.js'
32
33
@@ -38,13 +39,15 @@ router
38
39
```
39
40
40
41
or:
42
+
41
43
```ts
42
44
router
43
45
.group(() => {[...]})
44
46
.use([middleware.auth()])
45
47
```
46
48
47
49
Then, it is possible to get the user:
50
+
48
51
```ts
49
52
asyncfoo({ auth }: HttpContext) {
50
53
const user =auth.getUserOrFail() // type: CustomSupabaseUser defined in the guard
@@ -62,4 +65,5 @@ A list of examples is available [here](samples/) to show the possible implementa
62
65
4.**with-both-and-role-based:** version combining the above 2 samples, adding a decorator to build a role access based application - [README](samples/with-both-and-role-based/README.md)
63
66
64
67
## License
65
-
This project is Open Source software released under the [MIT license.](LICENSE.md)
68
+
69
+
This project is Open Source software released under the [MIT license.](LICENSE.md)
This version doesn't modify the code provided by the package. It just add an `auth.spec.ts` test that shows how to test routes that are **secure with supabase**.
3
+
This version doesn't modify the code provided by the package. It just add an `auth.spec.ts` test that shows how to test routes that are **secure with supabase**.
0 commit comments