Skip to content

Commit 1c5ef5b

Browse files
authored
Update middleware.ts
1 parent b538ac1 commit 1c5ef5b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/middleware.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ const authMiddleware = withAuth(
1212
function onSuccess(_req) {
1313
// you can get a token from the request object(req.nextauth.token) and do something with it
1414
// In here, do any kind of logging or tracking here or redirect to a custom URL
15+
},
16+
{
17+
callbacks: {
18+
authorized: async ({ token }) => {
19+
// If a user is authenticated, the token will be present
20+
// and the user is authorized.
21+
return !!token?.id;
22+
},
23+
},
1524
}
1625
);
1726

0 commit comments

Comments
 (0)