feat: add no expiration to token generated

This commit is contained in:
Mauricio Siu
2024-06-22 22:38:01 -06:00
parent 0add62f14d
commit 608db3d401
4 changed files with 55 additions and 34 deletions

View File

@@ -26,7 +26,7 @@ import {
updateAuthById,
verify2FA,
} from "../services/auth";
import { TimeSpan } from "lucia";
import { luciaToken } from "@/server/auth/token";
export const authRouter = createTRPCRouter({
createAdmin: publicProcedure
@@ -143,9 +143,9 @@ export const authRouter = createTRPCRouter({
const auth = await findAuthById(ctx.user.authId);
if (auth.token) {
await lucia.invalidateSession(auth.token);
await luciaToken.invalidateSession(auth.token);
}
const session = await lucia.createSession(auth?.id || "", {
const session = await luciaToken.createSession(auth?.id || "", {
expiresIn: 60 * 60 * 24 * 30,
});

View File

@@ -13,9 +13,10 @@ import { TRPCError, initTRPC } from "@trpc/server";
import type { CreateNextContextOptions } from "@trpc/server/adapters/next";
import superjson from "superjson";
import { ZodError } from "zod";
import { validateBearerToken, validateRequest } from "../auth/auth";
import { validateRequest } from "../auth/auth";
import type { Session, User } from "lucia";
import type { OperationMeta } from "openapi-trpc";
import { validateBearerToken } from "../auth/token";
/**
* 1. CONTEXT