Skip to content

Commit b1bb3e2

Browse files
docs(passport): add logout route for session-based #2999
1 parent 83148bd commit b1bb3e2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

content/recipes/passport.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,18 @@ async login(@Request() req) {
370370
}
371371
```
372372

373+
#### Logout route
374+
375+
To log out, we can create an additional route that invokes `res.logout()` to clear the user's session. This is a typical approach used in session-based authentication, but it does not apply to JWTs.
376+
377+
```typescript
378+
@UseGuards(LocalAuthGuard)
379+
@Post('auth/logout')
380+
async logout(@Request() req) {
381+
return req.logout();
382+
}
383+
```
384+
373385
#### JWT functionality
374386

375387
We're ready to move on to the JWT portion of our auth system. Let's review and refine our requirements:

0 commit comments

Comments
 (0)