fix(auth): redirect active sessions from /login
/api/auth/status did not expose whether the auth cookie corresponds to a valid dashboard session, so /login could only detect "auth disabled" (requireLogin === false) and not "already logged in". Add authenticated to the status response and redirect from /login when it's true.
This commit is contained in:
@@ -24,6 +24,7 @@ export async function GET() {
|
||||
hasPassword: !!settings.password,
|
||||
displayName,
|
||||
loginMethod,
|
||||
authenticated: !!session,
|
||||
oidcName: oidcName || null,
|
||||
oidcEmail: oidcEmail || null,
|
||||
oidcLogin: !!session?.oidc,
|
||||
@@ -37,6 +38,7 @@ export async function GET() {
|
||||
hasPassword: false,
|
||||
displayName: "Password user",
|
||||
loginMethod: "Password",
|
||||
authenticated: false,
|
||||
oidcName: null,
|
||||
oidcEmail: null,
|
||||
oidcLogin: false,
|
||||
|
||||
@@ -37,7 +37,7 @@ export default function LoginPage() {
|
||||
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
if (data.requireLogin === false) {
|
||||
if (data.authenticated === true || data.requireLogin === false) {
|
||||
window.location.assign("/dashboard");
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user