27 lines
No EOL
860 B
Svelte
27 lines
No EOL
860 B
Svelte
<script lang="ts">
|
|
import {onMount} from "svelte";
|
|
import {enforce_auth, enforce_session} from "../../lib/auth";
|
|
import {Logger, logSetup} from "../../lib/logger";
|
|
|
|
let logger = new Logger("admin/+page.svelte");
|
|
logSetup();
|
|
|
|
// this page requires session and mfa auth.
|
|
onMount(async () => {
|
|
let st_result = await enforce_session();
|
|
if (!st_result[0]) {
|
|
// Session token is invalid. redirect to login
|
|
window.location = "/auth/login";
|
|
return;
|
|
}
|
|
let at_result = await enforce_auth();
|
|
if (!at_result[0]) {
|
|
// Auth token is invalid. Redirect to mfa page.
|
|
window.location = "/auth/mfa";
|
|
return;
|
|
}
|
|
const api_token = at_result[1];
|
|
|
|
// user is fully authenticated and permitted to proceed
|
|
})
|
|
</script> |