Replace unauthorized status with a redirect

This commit is contained in:
Zef Hemel
2023-07-04 16:53:39 +02:00
parent 5ff9a5692b
commit f39ab26cea
2 changed files with 10 additions and 13 deletions
+3 -6
View File
@@ -218,8 +218,7 @@ export class HttpServer {
}
return;
} else {
response.status = 401;
response.body = "Unauthorized";
response.redirect("/.auth");
return;
}
} else {
@@ -232,8 +231,7 @@ export class HttpServer {
if (!excludedPaths.includes(request.url.pathname)) {
const authCookie = await cookies.get("auth");
if (!authCookie) {
response.status = 401;
response.body = "Unauthorized, please authenticate";
response.redirect("/.auth");
return;
}
const [username, hashedPassword] = authCookie.split(":");
@@ -243,8 +241,7 @@ export class HttpServer {
hashedPassword,
)
) {
response.status = 401;
response.body = "Invalid username/password, please reauthenticate";
response.redirect("/.auth");
return;
}
}