fix: fix redirect on auth

This commit is contained in:
Théo 2023-09-20 13:12:16 +02:00
parent c3c1d4bf22
commit 9e43d220d7
4 changed files with 8 additions and 21 deletions

View file

@ -46,7 +46,9 @@ export const actions = {
path: '/' path: '/'
}); });
throw redirect(303, '/dashboard'); return {
form
};
} }
form.errors.passwd = ["Nom d'utilisateur ou mot de passe incorrect"]; form.errors.passwd = ["Nom d'utilisateur ou mot de passe incorrect"];

View file

@ -10,17 +10,7 @@
export let data: PageData; export let data: PageData;
const { form, errors, enhance } = superForm(data.form, { const { form, errors, enhance } = superForm(data.form);
onResult({ result }) {
switch (result.type) {
case 'redirect':
goto(result.location, {
replaceState: true
});
break;
}
}
});
</script> </script>
<div class="flex h-screen w-full"> <div class="flex h-screen w-full">

View file

@ -125,7 +125,9 @@ export const actions = {
path: '/' path: '/'
}); });
throw redirect(303, '/dashboard'); return {
form
};
} }
if (res.status === 400) { if (res.status === 400) {

View file

@ -1,9 +1,7 @@
<script lang="ts"> <script lang="ts">
import { goto } from '$app/navigation';
import { fade } from 'svelte/transition'; import { fade } from 'svelte/transition';
import { superForm } from 'sveltekit-superforms/client'; import { superForm } from 'sveltekit-superforms/client';
import type { PageData, Snapshot } from './$types'; import type { PageData, Snapshot } from './$types';
import Button from '$lib/components/ui/Button.svelte'; import Button from '$lib/components/ui/Button.svelte';
@ -20,11 +18,6 @@
case 'error': case 'error':
confirmation = false; confirmation = false;
break; break;
case 'redirect':
goto(result.location, {
replaceState: true
});
break;
} }
} }
}); });