diff --git a/components/FormField.vue b/components/FormField.vue
index 0f22a7e..657c58d 100644
--- a/components/FormField.vue
+++ b/components/FormField.vue
@@ -46,7 +46,7 @@ provide(formGroupExtras, {
@@ -54,15 +54,15 @@ provide(formGroupExtras, {
diff --git a/components/YForm.vue b/components/YForm.vue
index 8247251..eb34bd8 100644
--- a/components/YForm.vue
+++ b/components/YForm.vue
@@ -19,7 +19,7 @@ withDefaults(
-
+
{
const isLoggedIn = useIsLoggedIn()
const settings = await useSettings()
- useRedirectUrl().value = (from.query.r as string) || null
- if (useRedirectUrl().value && to.name === 'login') {
- to.query.r = useRedirectUrl().value
+ const redirectUrl = useRedirectUrl()
+ if (to.query.r) {
+ redirectUrl.value = to.query.r as string
+ if (to.name !== 'login') {
+ return navigateTo({ path: '/login', query: { r: to.query.r } })
+ }
+ } else {
+ redirectUrl.value = null
}
if (to.name === 'login') {
diff --git a/pages/login.vue b/pages/login.vue
index de205c7..57cabf1 100644
--- a/pages/login.vue
+++ b/pages/login.vue
@@ -15,6 +15,7 @@ useHead({
})
const isLoggedIn = useIsLoggedIn()
+const redirectUrl = useRedirectUrl()
const { handleSubmit, setErrors } = useForm({
validationSchema: toTypedSchema(
@@ -32,10 +33,8 @@ const login = handleSubmit(async (form) => {
})
if (!error.value) {
- const redirectUrl = useRedirectUrl().value
-
- if (redirectUrl) {
- await navigateTo(atob(redirectUrl), { external: true })
+ if (redirectUrl.value) {
+ await navigateTo(atob(redirectUrl.value), { external: true })
}
isLoggedIn.value = true
@@ -50,9 +49,18 @@ const login = handleSubmit(async (form) => {
-
+
+
+