fix: close account authorization gaps (#755)

This commit is contained in:
Thomas Durieux
2026-07-22 04:29:04 +02:00
committed by GitHub
parent aab6ccf7fc
commit beef8387ae
7 changed files with 176 additions and 28 deletions
+22
View File
@@ -0,0 +1,22 @@
import * as express from "express";
export function isDisabledAccount(
status: string | undefined
): status is "banned" | "removed" {
return status === "banned" || status === "removed";
}
export function getLoginToken(
req: Pick<express.Request, "headers" | "body">
): string | null {
const authorization = req.headers.authorization;
if (typeof authorization === "string") {
const match = authorization.match(/^Bearer\s+(.+)$/i);
if (match) return match[1].trim();
}
if (req.body && typeof req.body.token === "string") {
return req.body.token.trim() || null;
}
return null;
}