Simple actual auth

This commit is contained in:
2025-09-23 23:15:44 +02:00
parent 32291f19b5
commit e00a589ae6
6 changed files with 270 additions and 3 deletions
+5 -2
View File
@@ -4,6 +4,7 @@ import {
} from 'http-status-codes';
import { narrow } from "@/types/typeUtils";
import { CLIENT_AUTH_TOKENS, SERVER_AUTH_TOKENS } from "./auth";
import { initDb } from "../db";
type Intents = 'server' | 'client';
@@ -57,7 +58,7 @@ export async function POST(req: NextRequest) {
switch (narrowIntents(intents[0])) {
case 'server':
SERVER_AUTH_TOKENS[token] = {
user_id, // placeholder
user_id,
server_ip: String(server_ip),
};
return NextResponse.json({ message: "ok", token });
@@ -67,4 +68,6 @@ export async function POST(req: NextRequest) {
default:
return NextResponse.json({ message: 'Invalid intentions' }, { status: StatusCodes.BAD_REQUEST });
}
}
}
initDb();