Redis logout WIP
This commit is contained in:
parent
dd0265f3f5
commit
21cc160f8f
3 changed files with 16 additions and 0 deletions
|
|
@ -10,6 +10,7 @@ import {
|
|||
import Google from "next-auth/providers/google";
|
||||
import Credentials from "next-auth/providers/credentials";
|
||||
import Apple from "next-auth/providers/apple";
|
||||
import { Redis } from "ioredis";
|
||||
|
||||
const headers = { Authorization: `Token ${process.env.ZAMMAD_API_TOKEN}` };
|
||||
|
||||
|
|
@ -122,6 +123,11 @@ export const authOptions: NextAuthOptions = {
|
|||
return roles.includes("admin") || roles.includes("agent");
|
||||
},
|
||||
session: async ({ session, token }) => {
|
||||
const redis = new Redis(process.env.REDIS_URL);
|
||||
const isInvalidated = await redis.get(`invalidated:${token.sub}`);
|
||||
if (isInvalidated) {
|
||||
return null;
|
||||
}
|
||||
// @ts-ignore
|
||||
session.user.roles = token.roles ?? [];
|
||||
// @ts-ignore
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue