Redirect after login and register
This commit is contained in:
+11
-2
@@ -6,6 +6,7 @@ definePageMeta({
|
||||
});
|
||||
const { fetch } = useUserSession();
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const localePath = useLocalePath();
|
||||
const { isValid, resetValidation, validate } = useForm('formRef');
|
||||
const validation = useValidation();
|
||||
@@ -28,7 +29,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 === 404) {
|
||||
@@ -118,7 +127,7 @@ async function submit() {
|
||||
$t('auth.login')
|
||||
}}</VaButton>
|
||||
<VaButton
|
||||
:to="$localePath('/register')"
|
||||
:to="$localePath({ path: '/register', query: route.query })"
|
||||
border-color="primary"
|
||||
preset="secondary"
|
||||
>{{ $t('auth.register_instead') }}</VaButton
|
||||
|
||||
Reference in New Issue
Block a user