diff --git a/src/i18n/en/register.json b/src/i18n/en/register.json index b05b88b..e8b610d 100644 --- a/src/i18n/en/register.json +++ b/src/i18n/en/register.json @@ -8,10 +8,11 @@ "password": "Password", "password_error": "This password is not valid.", "password_validation_1": "Minimum 8 characters", - "password_validation_2": "One uppercase", - "password_validation_3": "One lowercase", - "password_validation_4": "One number", - "password_validation_5": "One special character", + "password_validation_2": "Maximum 32 characters", + "password_validation_3": "One uppercase", + "password_validation_4": "One lowercase", + "password_validation_5": "One number", + "password_validation_6": "One special character", "repeat_password": "Repeat password", "repeat_password_error": "Passwords do not match.", "question": "Already have an account?", diff --git a/src/i18n/es/register.json b/src/i18n/es/register.json index 1868267..67b517c 100644 --- a/src/i18n/es/register.json +++ b/src/i18n/es/register.json @@ -8,10 +8,11 @@ "password": "Contraseña", "password_error": "Esta contraseña no es válida.", "password_validation_1": "Mínimo 8 caracteres", - "password_validation_2": "Una mayúscula", - "password_validation_3": "Una minúscula", - "password_validation_4": "Un número", - "password_validation_5": "Un carácter especial", + "password_validation_2": "Máximo 32 caracteres", + "password_validation_3": "Una mayúscula", + "password_validation_4": "Una minúscula", + "password_validation_5": "Un número", + "password_validation_6": "Un carácter especial", "repeat_password": "Repetir contraseña", "repeat_password_error": "Las contraseñas no coinciden.", "question": "¿Ya tienes una cuenta?", diff --git a/src/middleware/auth.ts b/src/middleware/01.refreshSession.global.ts similarity index 74% rename from src/middleware/auth.ts rename to src/middleware/01.refreshSession.global.ts index abd9e63..311a5a4 100644 --- a/src/middleware/auth.ts +++ b/src/middleware/01.refreshSession.global.ts @@ -1,6 +1,4 @@ export default defineNuxtRouteMiddleware(async (middleware) => { - const nuxtApp = useNuxtApp(); - const localeRoute = useLocaleRoute(); const { loggedIn, fetch, session, clear } = useUserSession(); const { extractTokenData } = useJwt(); @@ -25,12 +23,4 @@ export default defineNuxtRouteMiddleware(async (middleware) => { await fetch(); } } - - // Si el usuario no está logueado, lo redirige al login - if (!loggedIn.value) { - const loginRoute = localeRoute('login', nuxtApp.$i18n.locale); - const loginPath = loginRoute != null ? loginRoute.path : '/'; - - return navigateTo(loginPath); - } }); diff --git a/src/middleware/disabledWithSession.ts b/src/middleware/disabledWithSession.ts new file mode 100644 index 0000000..7de2f28 --- /dev/null +++ b/src/middleware/disabledWithSession.ts @@ -0,0 +1,13 @@ +export default defineNuxtRouteMiddleware(async (middleware) => { + const nuxtApp = useNuxtApp(); + const localeRoute = useLocaleRoute(); + const { loggedIn } = useUserSession(); + + // Si el usuario está logueado, lo redirige a su biblioteca + if (loggedIn.value) { + const libraryRoute = localeRoute('library', nuxtApp.$i18n.locale.value); + const libraryPath = libraryRoute != null ? libraryRoute.path : '/'; + + return navigateTo(libraryPath); + } +}); diff --git a/src/middleware/enabledWithSession.ts b/src/middleware/enabledWithSession.ts new file mode 100644 index 0000000..2ca796f --- /dev/null +++ b/src/middleware/enabledWithSession.ts @@ -0,0 +1,13 @@ +export default defineNuxtRouteMiddleware(async (middleware) => { + const nuxtApp = useNuxtApp(); + const localeRoute = useLocaleRoute(); + const { loggedIn } = useUserSession(); + + // Si el usuario no está logueado, lo redirige al login + if (!loggedIn.value) { + const loginRoute = localeRoute('login', nuxtApp.$i18n.locale.value); + const loginPath = loginRoute != null ? loginRoute.path : '/'; + + return navigateTo(loginPath); + } +}); diff --git a/src/pages/(user)/library.vue b/src/pages/(user)/library.vue index 1eaef24..f9ec36a 100644 --- a/src/pages/(user)/library.vue +++ b/src/pages/(user)/library.vue @@ -10,7 +10,7 @@ defineI18nRoute({ }); definePageMeta({ - middleware: ["auth"], + middleware: ["enabled-with-session"], }); useHead({ diff --git a/src/pages/auth/login.vue b/src/pages/auth/login.vue index d21aa9d..9ac7331 100644 --- a/src/pages/auth/login.vue +++ b/src/pages/auth/login.vue @@ -11,6 +11,10 @@ defineI18nRoute({ }, }); +definePageMeta({ + middleware: ["disabled-with-session"], +}); + useHead({ title: t('home.title') + ' - ' + t('login.title'), meta: [ diff --git a/src/pages/auth/register.vue b/src/pages/auth/register.vue index 35df7c9..d605585 100644 --- a/src/pages/auth/register.vue +++ b/src/pages/auth/register.vue @@ -1,5 +1,10 @@