fixed logout, now using account/app/server architecture

This commit is contained in:
ari melody 2024-07-05 14:47:17 +01:00
parent 7f993ee538
commit 5e44cdf73a
Signed by: ari
GPG key ID: CF99829C92678188

View file

@ -1,5 +1,8 @@
<script> <script>
import * as api from '$lib/api.js';
import { account, logged_in } from '$lib/stores/account.js'; import { account, logged_in } from '$lib/stores/account.js';
import { server } from '$lib/client/server.js';
import { app } from '$lib/client/app.js';
import { play_sound } from '$lib/sound.js'; import { play_sound } from '$lib/sound.js';
import { getTimeline } from '$lib/timeline.js'; import { getTimeline } from '$lib/timeline.js';
import { getNotifications } from '$lib/notifications.js'; import { getNotifications } from '$lib/notifications.js';
@ -59,7 +62,22 @@
async function log_out() { async function log_out() {
if (!confirm("This will log you out. Are you sure?")) return; if (!confirm("This will log you out. Are you sure?")) return;
await get(client).logout();
const res = await api.revokeToken(
get(server).host,
get(app).id,
get(app).secret,
get(app).token
);
if (!res.ok)
console.warn("Token revocation failed! Dumping data anyways");
logged_in.set(false);
account.set(false);
app.set(false);
server.set(false);
goto("/"); goto("/");
} }
</script> </script>