fix: read-after-write issues (#215)
* fix: read-after-write issues * fix: coderabbit comments * fix: clear cache on invite * fix: use primary after a read
This commit is contained in:
committed by
GitHub
parent
abacf66155
commit
f454449365
@@ -20,6 +20,7 @@ import {
|
||||
getUserAccount,
|
||||
} from '@openpanel/db';
|
||||
import { sendEmail } from '@openpanel/email';
|
||||
import { deleteCache } from '@openpanel/redis';
|
||||
import {
|
||||
zRequestResetPassword,
|
||||
zResetPassword,
|
||||
@@ -74,6 +75,7 @@ export const authRouter = createTRPCRouter({
|
||||
deleteSessionTokenCookie(ctx.setCookie);
|
||||
if (ctx.session?.session?.id) {
|
||||
await invalidateSession(ctx.session.session.id);
|
||||
await deleteCache(`validateSession:${ctx.session.session.id}`);
|
||||
}
|
||||
}),
|
||||
signInOAuth: publicProcedure
|
||||
@@ -333,6 +335,7 @@ export const authRouter = createTRPCRouter({
|
||||
const session = await validateSessionToken(token);
|
||||
|
||||
if (session.session) {
|
||||
await deleteCache(`validateSession:${session.session.id}`);
|
||||
// Re-set the cookie with updated expiration
|
||||
setSessionTokenCookie(ctx.setCookie, token, session.session.expiresAt);
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user