add(ui): ability to log out
This commit is contained in:
parent
d2ca9e23d3
commit
b3cac5f97a
29 changed files with 499 additions and 124 deletions
|
@ -34,6 +34,9 @@ media_theme_pref();
|
|||
(() => {
|
||||
const self = reg_ns("atto");
|
||||
|
||||
// init
|
||||
use("me", () => {});
|
||||
|
||||
// env
|
||||
self.DEBOUNCE = [];
|
||||
self.OBSERVERS = [];
|
||||
|
|
30
crates/app/src/public/js/me.js
Normal file
30
crates/app/src/public/js/me.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
(() => {
|
||||
const self = reg_ns("me");
|
||||
|
||||
self.define("logout", async () => {
|
||||
if (
|
||||
!(await trigger("atto::confirm", [
|
||||
"Are you sure you would like to do this?",
|
||||
]))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
fetch("/api/v1/auth/logout", {
|
||||
method: "POST",
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
trigger("atto::toast", [
|
||||
res.ok ? "sucesss" : "error",
|
||||
res.message,
|
||||
]);
|
||||
|
||||
if (res.ok) {
|
||||
setTimeout(() => {
|
||||
window.location.href = "/";
|
||||
}, 150);
|
||||
}
|
||||
});
|
||||
});
|
||||
})();
|
Loading…
Add table
Add a link
Reference in a new issue