mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
feat: use custom verify token policy (#5836)
This commit is contained in:
@@ -96,6 +96,24 @@ export const NextAuthOptionsProvider: FactoryProvider<NextAuthOptions> = {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
prismaAdapter.createVerificationToken = async data => {
|
||||||
|
await session.set(
|
||||||
|
`${data.identifier}:${data.token}`,
|
||||||
|
Date.now() + session.sessionTtl
|
||||||
|
);
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
prismaAdapter.useVerificationToken = async ({ identifier, token }) => {
|
||||||
|
const expires = await session.get(`${identifier}:${token}`);
|
||||||
|
if (expires) {
|
||||||
|
return { identifier, token, expires: new Date(expires) };
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const nextAuthOptions: NextAuthOptions = {
|
const nextAuthOptions: NextAuthOptions = {
|
||||||
providers: [],
|
providers: [],
|
||||||
adapter: prismaAdapter,
|
adapter: prismaAdapter,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { SessionCache } from '../cache';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class SessionService {
|
export class SessionService {
|
||||||
private readonly prefix = 'session:';
|
private readonly prefix = 'session:';
|
||||||
private readonly sessionTtl = 30 * 60 * 1000; // 30 min
|
public readonly sessionTtl = 30 * 60 * 1000; // 30 min
|
||||||
|
|
||||||
constructor(private readonly cache: SessionCache) {}
|
constructor(private readonly cache: SessionCache) {}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user