Force redirection to home page of requesting /auth when logged

This commit is contained in:
nemunaire 2022-05-15 13:18:43 +02:00
parent 4872a74155
commit cb460ff695
1 changed files with 11 additions and 13 deletions

View File

@ -1,20 +1,9 @@
<script context="module">
import { session } from '$app/stores';
export function load() {
if (session.id) {
return { redirect: '/', status: 302 };
}
return { };
}
</script>
<script>
import { goto } from '$app/navigation';
import { page } from '$app/stores'
import AuthButton from '../components/AuthButton.svelte';
import { user } from '../stores/user';
let auth = { username: "", password: "" };
let pleaseWait = false;
@ -30,7 +19,6 @@
.then((response) => {
response.json().then((auth) => {
pleaseWait = false;
$session = auth;
if (next && next.indexOf('//') === -1) {
goto(next)
} else {
@ -48,6 +36,16 @@
});
});
}
$: {
if ($user && $user.id) {
if (next && next.indexOf('//') === -1) {
goto(next)
} else {
goto(".");
}
}
}
</script>
<div class="row">