From 0b9be710d8135212f08e0c300f4b0445cfd3f6d9 Mon Sep 17 00:00:00 2001 From: lifegpc Date: Sun, 16 Jul 2023 07:52:16 +0800 Subject: [PATCH] Add secure if login with https protocol --- components/CreateRootUser.tsx | 3 +++ components/Login.tsx | 3 +++ 2 files changed, 6 insertions(+) diff --git a/components/CreateRootUser.tsx b/components/CreateRootUser.tsx index c77b749..ff07db8 100644 --- a/components/CreateRootUser.tsx +++ b/components/CreateRootUser.tsx @@ -51,6 +51,9 @@ export default class CreateRootUser extends Component { b.append("password", p2); b.append("t", t.toString()); b.append("set_cookie", "1"); + if (document.location.protocol === "https:") { + b.append("secure", "1"); + } const re2 = await fetch("/api/token", { method: "PUT", body: b }); const token = await re2.json(); if (!token.ok) { diff --git a/components/Login.tsx b/components/Login.tsx index 1199dc0..6bccf5b 100644 --- a/components/Login.tsx +++ b/components/Login.tsx @@ -43,6 +43,9 @@ export default class Login extends Component { b.append("password", p2); b.append("t", t.toString()); b.append("set_cookie", "1"); + if (document.location.protocol === "https:") { + b.append("secure", "1"); + } const re2 = await fetch("/api/token", { method: "PUT", body: b }); const token = await re2.json(); if (!token.ok) {