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