fix: fix redirect on auth
This commit is contained in:
parent
c3c1d4bf22
commit
9e43d220d7
4 changed files with 8 additions and 21 deletions
|
@ -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"];
|
||||||
|
|
|
@ -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">
|
||||||
|
|
|
@ -125,7 +125,9 @@ export const actions = {
|
||||||
path: '/'
|
path: '/'
|
||||||
});
|
});
|
||||||
|
|
||||||
throw redirect(303, '/dashboard');
|
return {
|
||||||
|
form
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res.status === 400) {
|
if (res.status === 400) {
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue