generated from t/malachite
add: login
This commit is contained in:
parent
ce9ce4f635
commit
8c86dd6cda
13 changed files with 407 additions and 25 deletions
24
app/public/tokens.js
Normal file
24
app/public/tokens.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
globalThis.LOGIN_ACCOUNT_TOKENS = JSON.parse(
|
||||
window.localStorage.getItem("login_account_tokens") || "[]",
|
||||
);
|
||||
|
||||
function save_login_account_tokens() {
|
||||
window.localStorage.setItem(
|
||||
"login_account_tokens",
|
||||
JSON.stringify(LOGIN_ACCOUNT_TOKENS),
|
||||
);
|
||||
}
|
||||
|
||||
function user_logout() {
|
||||
if (!confirm("Are you sure you would like to do this?")) {
|
||||
return;
|
||||
}
|
||||
|
||||
fetch("/api/v1/auth/logout", { method: "POST" })
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
if (res.ok) {
|
||||
window.location.href = "/";
|
||||
}
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue