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

Conversation

Projects
None yet
3 participants
@herbertscruz
Collaborator

herbertscruz commented Oct 22, 2017

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

@jhesgodi

This comment has been minimized.

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

This comment has been minimized.

Collaborator

herbertscruz commented Nov 4, 2017

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

This comment has been minimized.

Collaborator

herbertscruz commented Nov 9, 2017

Hello @pi0 ,

have you encountered any problems in this PR?

@pi0

This comment has been minimized.

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