feat: citizenship applications

This commit is contained in:
Ivan Rezchikov
2026-06-23 19:03:10 +03:00
parent 58ec75c948
commit c60ab9e8f9
44 changed files with 1254 additions and 130 deletions
+5 -3
View File
@@ -2,7 +2,9 @@ import { SignJWT, jwtVerify } from "jose";
import { cookies } from "next/headers";
import { cookieConfig } from "@/lib/cookieConfig";
const secret = new TextEncoder().encode(process.env.JWT_SECRET!);
function getSecret() {
return new TextEncoder().encode(process.env.JWT_SECRET!);
}
async function signJwt(userId: string) {
return await new SignJWT({})
@@ -10,7 +12,7 @@ async function signJwt(userId: string) {
.setSubject(userId)
.setIssuedAt()
.setExpirationTime(`${process.env.SESSION_MAX_AGE}s`)
.sign(secret);
.sign(getSecret());
}
export async function createSession(userId: string) {
@@ -29,7 +31,7 @@ export async function getSessionUserId(): Promise<string | null> {
if (!token) return null;
try {
const { payload } = await jwtVerify(token, secret);
const { payload } = await jwtVerify(token, getSecret());
return payload.sub ?? null;
} catch {
return null;
+5
View File
@@ -7,6 +7,11 @@ export async function setTokens(accessToken: string, refreshToken: string, ttl:
store.set("refresh_token", refreshToken, { ...cookieConfig, path: "/", maxAge: ttl * 7 * 24 * 60 * 60 });
}
export async function getAccessToken() {
const store = await cookies();
return store.get("access_token")?.value ?? null;
}
export async function deleteOAuthCookies() {
const store = await cookies();
store.delete("pkce_verifier");