feat: complete auth and gateway agnostic billing implementation

This commit is contained in:
2026-08-13 11:32:35 +05:30
parent f25e338430
commit 63bf71a50c
9 changed files with 652 additions and 188 deletions

View File

@@ -0,0 +1,23 @@
import { NextResponse } from "next/server"
export async function POST(request: Request) {
try {
const { email } = await request.json()
if (!email) {
return NextResponse.json({ success: false, error: "Email is required" }, { status: 400 })
}
// In a real application, you would generate a secure reset token,
// save it in the database with an expiry, and send an email using SES/SendGrid/SMTP.
// For now, we return a successful response to simulate the flow.
console.log(`Password reset requested for: ${email}`)
return NextResponse.json({ success: true, message: "Reset instructions sent." })
} catch (error) {
console.error("Forgot password API error:", error)
return NextResponse.json({ success: false, error: "Internal server error" }, { status: 500 })
}
}

View File

@@ -1,43 +0,0 @@
import { NextResponse } from 'next/server';
export async function POST(request: Request) {
try {
const body = await request.json();
const { email, password } = body;
let role = null;
if (email === "demo@pragativeer.com" && password === "Pv9#kL2$mQ8!vX4@") {
role = "user";
} else if (email === "admin@pragativeer.com" && password === "admin123") {
role = "admin";
}
if (role) {
const response = NextResponse.json({ success: true, role });
// Set HttpOnly cookie
response.cookies.set({
name: 'auth_token',
value: role,
httpOnly: true,
secure: process.env.NODE_ENV === 'production',
sameSite: 'lax',
path: '/',
maxAge: 60 * 60 * 24 * 7 // 1 week
});
return response;
}
return NextResponse.json(
{ success: false, error: 'Invalid email or password' },
{ status: 401 }
);
} catch (error) {
return NextResponse.json(
{ success: false, error: 'Bad request' },
{ status: 400 }
);
}
}