aboutsummaryrefslogtreecommitdiffstats
path: root/code/api/wwwroot/scripts/logged-in-base.js
blob: ae20f3c20989e7f3f275a9bfdbf79f6e83fdfc2b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
async function load_session() {
    const sessionResponse = await api.get_session_async();
    if (!sessionResponse.ok) {
        show_error(strings.anErrorOccured.v(), strings.tryAgainSoon.v());
        console.error("/session responded unsuccessfully");
    }
    session.set(await json_or_default_async(sessionResponse, {}));
}

async function init() {
    await load_session();
    document.querySelectorAll(".do-logout").forEach(el => {
        el.addEventListener("click", () => logout_and_exit());
    })

}

document.addEventListener("DOMContentLoaded", init);