feat(platform): add Discord onboarding and Velocity gate
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
"use server";
|
||||
|
||||
import { hashToken, SESSION_COOKIE_NAME } from "@minecraft-account-manager/auth";
|
||||
import { sessions } from "@minecraft-account-manager/database";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { cookies } from "next/headers";
|
||||
import { redirect } from "next/navigation";
|
||||
import { db } from "@/lib/database";
|
||||
|
||||
export async function logout() {
|
||||
const cookieStore = await cookies();
|
||||
const token = cookieStore.get(SESSION_COOKIE_NAME)?.value;
|
||||
|
||||
if (token) {
|
||||
await db
|
||||
.update(sessions)
|
||||
.set({ revokedAt: new Date() })
|
||||
.where(eq(sessions.tokenHash, hashToken(token)));
|
||||
}
|
||||
|
||||
cookieStore.delete(SESSION_COOKIE_NAME);
|
||||
redirect("/");
|
||||
}
|
||||
Reference in New Issue
Block a user