-
Notifications
You must be signed in to change notification settings - Fork 927
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
Improvements #11
Improvements #11
Conversation
@herbertscruz Thank you for taking the time for submitting this improvement, its great. I have a question: const options = {
loginRoute: '/login',
excluded: [
'index',
'login'
// ...
]
}
export default function authMiddleware ({ store, redirect, route }) {
// If user not logged in, redirect default login
const notExcluded = !options.excluded.includes(route.name)
const notLoggedIn = !store.getters['auth/loggedIn']
if (notExcluded && notLoggedIn) {
return redirect(options.loginRoute)
}
} Is there a proper way to do it from the nuxt.config.js rather than skipping them on the middleware itself? |
Hello @jhesgodi Thanks for the recognition of my work, it's a pleasure to help. If you want a reusable component, you can include it in nuxt.config.js. However, I think this solution is particular to each application, because in most cases it will be necessary to verify the role of the user and each application has its particularities. |
Hello @pi0 , have you encountered any problems in this PR? |
Emm no Just didn't find some time to test changes on my local env. Sorry for delaying. Will merge and release now so we can check it later :) |
Solved issue #6 and accept suggestion of the issue #3.