Skip to content
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

Customizable Login URL #54

Open
itpropro opened this issue Sep 21, 2024 · 7 comments
Open

Customizable Login URL #54

itpropro opened this issue Sep 21, 2024 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@itpropro
Copy link
Owner

The login urls are currently fixed to /auth/login or /auth/PROVIDER/login.
It can help with i18n or other cases to have them customizable.

Follow up of #53

@itpropro itpropro added the enhancement New feature or request label Sep 21, 2024
@itpropro itpropro self-assigned this Sep 21, 2024
@mrleblanc101
Copy link

I think instead of forcing the directory structure to be auth/login, we should have an option to pass the route name (ex: just login). Then it would be possible to automatically detect if i18n is installed, if it is, pass the name of the route to localeRoute and retrieve the localized name (ex: login__fr or login__en) or if i18n is not installed, simply resolve the provided name

@itpropro
Copy link
Owner Author

I think instead of forcing the directory structure to be auth/login, we should have an option to pass the route name (ex: just login). Then it would be possible to automatically detect if i18n is installed, if it is, pass the name of the route to localeRoute and retrieve the localized name (ex: login__fr or login__en) or if i18n is not installed, simply resolve the provided name

That's a good idea. This would only apply if nuxt-i18n is installed, no if vue-i18n is used (there could me multiple reasons for that), so I would also provide an array option with route rules that all redirect to your custom login page, so if wanted, the logic can be handled there individually. That would also handle some use cases outside or i18n.

@mrleblanc101
Copy link

Or maybe a onRedirect callback like @nuxtjs/auth-next and people handle the translation themselves

@itpropro
Copy link
Owner Author

A custom login route is in the backlog, detecting i18n is probably not going to happen soon, as the users can implement their own login in a custom login site to handle multiple languages.
Internationalized routes are pretty rare and more of a niche feature that adds a lot of complexity. Out of many projects I worked on for i18n, I only encountered one that actually did custom routes instead of translating the page, but I will still keep it in the backlog until I found a way to delegate this to the framework with something like callbacks/hooks that has minimal impact on the module.

@mrleblanc101
Copy link

mrleblanc101 commented Sep 24, 2024

Weird, I've done dozen of Nuxt 2 project and we've always translated the routes. To each their own 🤷‍♂️

I guess I prefer how @nuxtjs/auth-next handle their middleware, you define the routes for login, logout, home, callback URL and we use the onRedirect callback to translate the route ourselves. And then you either load the middleware globally using router.middleware (instead of the plugin injecting the middleware) and then you can use auth: false or auth: "guest" to override in the page component.

I don't like that the global middleware infer the pages from the file-system routing (which force the route URL).

@itpropro
Copy link
Owner Author

There are definitely different requirements in terms of i18n, I probably just had a lot of projects without translated routes :)
The middleware is just a convenience, why it is kept as simple as possible. You can also just disable the middleware and use your own one for redirecting as well as creating redirected routes to the auth paths.
Like I said, I will definitely look into custom urls, especially for the base part (auth), but I have to find a way that doesn't make it much more complex and which keeps it simple, if you do not want to use it.

@mrleblanc101
Copy link

@itpropro Yeah, I'll probably look into porting the middleware from @nuxtjs/i18n-next in my app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants