mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 10:25:58 +00:00
27 lines
690 B
TypeScript
27 lines
690 B
TypeScript
|
|
import { createSession, server, setSession } from "#/lib/zitadel";
|
||
|
|
import { NextRequest, NextResponse } from "next/server";
|
||
|
|
|
||
|
|
export async function POST(request: NextRequest) {
|
||
|
|
const body = await request.json();
|
||
|
|
if (body) {
|
||
|
|
const { loginName } = body;
|
||
|
|
|
||
|
|
const session = await createSession(server, loginName);
|
||
|
|
return NextResponse.json(session);
|
||
|
|
} else {
|
||
|
|
return NextResponse.error();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function PUT(request: NextRequest) {
|
||
|
|
const body = await request.json();
|
||
|
|
if (body) {
|
||
|
|
const { loginName } = body;
|
||
|
|
|
||
|
|
const session = await setSession(server, loginName);
|
||
|
|
return NextResponse.json(session);
|
||
|
|
} else {
|
||
|
|
return NextResponse.error();
|
||
|
|
}
|
||
|
|
}
|