chore: fix TS warning by type narrowing

`req.csrfToken` might be undefined according to `csrf-csrf`
provided types, so use type narrowing to make sure it exists,
before calling it
This commit is contained in:
Panagiotis Papadopoulos 2025-01-05 19:37:28 +01:00
parent d20a3bab2a
commit c36085e580

View File

@ -19,7 +19,7 @@ function index(req: Request, res: Response) {
const view = !utils.isElectron() && req.cookies["trilium-device"] === "mobile" ? "mobile" : "desktop";
const csrfToken = req.csrfToken();
const csrfToken = (typeof req.csrfToken === "function") ? req.csrfToken() : undefined;
log.info(`Generated CSRF token ${csrfToken} with secret ${res.getHeader("set-cookie")}`);
// We force the page to not be cached since on mobile the CSRF token can be