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

Improvements #11

Merged
merged 15 commits into from
Nov 9, 2017
Merged

Improvements #11

merged 15 commits into from
Nov 9, 2017

Conversation

herbertscruz
Copy link
Contributor

Solved issue #6 and accept suggestion of the issue #3.

@jhesgodi
Copy link

jhesgodi commented Nov 1, 2017

@herbertscruz Thank you for taking the time for submitting this improvement, its great.

I have a question:
Recently I added my own middleware for auth, and I'm looking for a way to exclude routes from the auth middleware.

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?

@herbertscruz
Copy link
Contributor Author

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.

@herbertscruz
Copy link
Contributor Author

Hello @pi0 ,

have you encountered any problems in this PR?

@pi0
Copy link
Member

pi0 commented Nov 9, 2017

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 :)

@pi0 pi0 merged commit 5d870c2 into nuxt-community:master Nov 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants