mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-21 17:36:38 +00:00
Remember Me Field in Login Request
This commit is contained in:
parent
0cd01e2c4e
commit
9b72f51b00
@ -6,6 +6,7 @@ import prisma from "@/app/prisma";
|
|||||||
interface Body {
|
interface Body {
|
||||||
username: string;
|
username: string;
|
||||||
password: string;
|
password: string;
|
||||||
|
remember?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function POST(request: NextRequest) {
|
export async function POST(request: NextRequest) {
|
||||||
@ -36,7 +37,7 @@ export async function POST(request: NextRequest) {
|
|||||||
return NextResponse.json({ error: "No JWT secret found" }, { status: 500 });
|
return NextResponse.json({ error: "No JWT secret found" }, { status: 500 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const token = jwt.sign({ id: user.id }, process.env.JWT_SECRET, { expiresIn: "7d" });
|
const token = jwt.sign({ id: user.id }, process.env.JWT_SECRET, { expiresIn: body.remember ? "7d" : "1h" });
|
||||||
|
|
||||||
return NextResponse.json({ message: "Login successful", token }, { status: 200 });
|
return NextResponse.json({ message: "Login successful", token }, { status: 200 });
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user