Tile windowing system
This commit is contained in:
parent
c6e6c5ca48
commit
43318fb8cd
35 changed files with 4659 additions and 360 deletions
19
app/api/users/[username]/credentials/[credId]/route.ts
Normal file
19
app/api/users/[username]/credentials/[credId]/route.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
export async function DELETE(
|
||||
req: NextRequest,
|
||||
{ params }: { params: Promise<{ username: string; credId: string }> },
|
||||
) {
|
||||
const token = req.cookies.get("token")?.value;
|
||||
if (!token) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||
|
||||
const { username, credId } = await params;
|
||||
|
||||
const res = await fetch(
|
||||
`http://localhost:3001/users/${encodeURIComponent(username)}/credentials/${encodeURIComponent(credId)}`,
|
||||
{ method: "DELETE", headers: { Authorization: `Bearer ${token}` } },
|
||||
);
|
||||
|
||||
if (!res.ok) return NextResponse.json({ error: "Upstream error" }, { status: res.status });
|
||||
return NextResponse.json({ success: true });
|
||||
}
|
||||
21
app/api/users/[username]/enroll/finish/route.ts
Normal file
21
app/api/users/[username]/enroll/finish/route.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
export async function POST(
|
||||
req: NextRequest,
|
||||
{ params }: { params: Promise<{ username: string }> },
|
||||
) {
|
||||
const token = req.cookies.get("token")?.value;
|
||||
if (!token) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||
|
||||
await params;
|
||||
const body = await req.json();
|
||||
|
||||
const res = await fetch("http://localhost:3001/auth/register/finish", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
|
||||
if (!res.ok) return NextResponse.json({ error: "Registration failed" }, { status: 400 });
|
||||
return NextResponse.json(await res.json());
|
||||
}
|
||||
22
app/api/users/[username]/enroll/start/route.ts
Normal file
22
app/api/users/[username]/enroll/start/route.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
export async function POST(
|
||||
req: NextRequest,
|
||||
{ params }: { params: Promise<{ username: string }> },
|
||||
) {
|
||||
const token = req.cookies.get("token")?.value;
|
||||
if (!token) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||
|
||||
const { username } = await params;
|
||||
const { password } = await req.json();
|
||||
|
||||
const res = await fetch("http://localhost:3001/auth/register/start", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: "Basic " + Buffer.from(`${username}:${password}`).toString("base64"),
|
||||
},
|
||||
});
|
||||
|
||||
if (!res.ok) return NextResponse.json({ error: "Invalid credentials" }, { status: 401 });
|
||||
return NextResponse.json(await res.json());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue