feat: complete auth and gateway agnostic billing implementation
This commit is contained in:
@@ -29,10 +29,23 @@ export default function LoginPage() {
|
||||
const data = await res.json()
|
||||
|
||||
if (data.success) {
|
||||
if (data.role === "admin") {
|
||||
router.push("/admin")
|
||||
} else {
|
||||
router.push("/dashboard")
|
||||
if (typeof window !== "undefined") {
|
||||
localStorage.setItem("activeUserId", data.token)
|
||||
// Create new session token for single-device login
|
||||
const sessionToken = crypto.randomUUID();
|
||||
localStorage.setItem("active_session_token", sessionToken);
|
||||
|
||||
fetch(`/api/users/${data.token}/session`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ session_token: sessionToken })
|
||||
}).finally(() => {
|
||||
if (data.role === "admin") {
|
||||
window.location.href = "/admin";
|
||||
} else {
|
||||
window.location.href = "/dashboard";
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
setError(data.error || "Invalid email or password.")
|
||||
@@ -76,7 +89,7 @@ export default function LoginPage() {
|
||||
<label className="text-sm font-bold text-foreground">
|
||||
Password
|
||||
</label>
|
||||
<Link href="#" className="text-xs font-bold text-[#00F0FF] hover:text-[#00F0FF]/80 transition-colors">Forgot password?</Link>
|
||||
<Link href="/forgot-password" className="text-xs font-bold text-[#00F0FF] hover:text-[#00F0FF]/80 transition-colors">Forgot password?</Link>
|
||||
</div>
|
||||
<div className="relative">
|
||||
<input
|
||||
|
||||
Reference in New Issue
Block a user