Redirect after login and register

This commit is contained in:
2025-08-05 23:40:46 +02:00
parent dc42258010
commit eac877752f
2 changed files with 22 additions and 4 deletions
+11 -2
View File
@@ -7,6 +7,7 @@ definePageMeta({
});
const { fetch } = useUserSession();
const router = useRouter();
const route = useRoute();
const localePath = useLocalePath();
const { isValid, resetValidation, validate } = useForm('formRef');
const validation = useValidation();
@@ -30,7 +31,15 @@ async function submit() {
body: form
});
await fetch();
await router.push(localePath('/'));
await router.push(
localePath(
(route.query.to
? typeof route.query.to === 'string'
? route.query.to
: route.query.to[0]
: '/') || '/'
)
);
return;
} catch (e) {
if (e instanceof Error && 'statusCode' in e && e.statusCode === 409) {
@@ -150,7 +159,7 @@ async function submit() {
$t('auth.register')
}}</VaButton>
<VaButton
:to="$localePath('/login')"
:to="$localePath({ path: '/login', query: route.query })"
border-color="primary"
preset="secondary"
>{{ $t('auth.login_instead') }}</VaButton