-
-
Notifications
You must be signed in to change notification settings - Fork 18
-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] Nuxt i18n - Locale changing after logging in / out #131
Comments
Hey @goela268! I believe it is not directly related to the module itself, but let's try to find a problem 😄
|
Hi! Thanks for your reply.
My guess is, that because both nuxt-i18n and nuxt-auth-sanctum save state using |
From what I know, all Have you tried to refresh the page once you selected the custom locale for the user? I assume it should be also reset regardless of authentication. |
Thanks for the detailed explanation. I've spent some time with the debugger, and you are right, the locale change happens right after the redirection to It's very odd, but as it has nothing to do with your library indeed, feel free to close this unless you have another idea. Anyway, thank you very much for your attempts at helping me! Much appreciated. |
You're welcome! The only suggestion I have in mind is to use some persistent storage for that, for example, cookies or local storage to prevent similar situations in the future. |
@manchenkoff Thus it has not directly anything to do with this library, it seems that there is a bug when redirecting using What do you think of giving the user the possibility to customize/intercept the path used for redirection on login & logout by providing a function? Not sure how that could look since I only recently migrated to Nuxt 3, from what I see, you can not pass a function within the nuxt config, Maybe there would be a way using hooks? If you would approve for this feature and maybe have an idea how it could look, I could give it a try over the weekend 😄 |
To be honest, it doesn't seem right for the authentication module 😄 In this case I would suggest disabling automatic redirects (by setting them to
Hooks are used as event listeners, but not for changing the configuration, so it would be the same as writing custom redirects with disabling defaults.
There is a way to pass a function via If you need any assistance with disabling module-provided redirects and writing your own logic, feel free to post questions here, I will try to help! |
Wow, I missed that this was possible. In that case I'll simply handle redirection myself. You're right, that's much better than providing interceptors for this specific use case. |
Everytime I login or logout, the currenctly selected Locale (from Nuxt i18n) changes to my configured default Locale.
For example, if my default locale is french, and I selected english, after login, it will be set to french. Same for logout.
There is no other circumstance when this behavior happens, and I'm really not sure how to debug, so I would like to ask if anyone has this behavior aswell. I even checked the code of nuxt-auth-sanctum and I can not really spot anything that could cause this, so apologies if it does not belong here.
Login Code:
Logout Code:
Sanctum Config:
The text was updated successfully, but these errors were encountered: