fix(login): redirect authenticated users away from login page
Authenticated users visiting /login are immediately redirected: admins to /today, all others to /. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { resolve } from '$app/paths';
|
||||
import { goto } from '$app/navigation';
|
||||
import { Button } from '$lib/components/ui/button/index.js';
|
||||
import { Input } from '$lib/components/ui/input/index.js';
|
||||
import { Label } from '$lib/components/ui/label/index.js';
|
||||
@@ -7,6 +8,14 @@
|
||||
import { Checkbox } from '$lib/components/ui/checkbox/index.js';
|
||||
import RequiredLabel from '$lib/components/layout/RequiredLabel.svelte';
|
||||
import { SvelteDate } from 'svelte/reactivity';
|
||||
import { authStore } from '$lib/stores/auth.svelte.js';
|
||||
|
||||
// Redirect authenticated users away from login page
|
||||
$effect(() => {
|
||||
if (authStore.isAuthenticated && authStore.hasLoaded) {
|
||||
goto(authStore.isAdmin() ? resolve('/today') : resolve('/'));
|
||||
}
|
||||
});
|
||||
|
||||
// zxcvbn-ts imports
|
||||
import { zxcvbn, zxcvbnOptions } from '@zxcvbn-ts/core';
|
||||
|
||||
Reference in New Issue
Block a user