Add secure if login with https protocol

This commit is contained in:
2023-07-16 07:52:16 +08:00
parent feef87aff8
commit 0b9be710d8
2 changed files with 6 additions and 0 deletions

View File

@@ -51,6 +51,9 @@ export default class CreateRootUser extends Component<Props> {
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) {

View File

@@ -43,6 +43,9 @@ export default class Login extends Component<Props> {
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) {