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

feat(middleware): add guest option in auth middleware #264

Merged
merged 2 commits into from
May 23, 2019
Merged

feat(middleware): add guest option in auth middleware #264

merged 2 commits into from
May 23, 2019

Conversation

ricardogobbosouza
Copy link
Member

In most cases you need to create guest middleware:

// middleware/guest.js
export default function({ store, redirect }) {
    if (store.state.auth.loggedIn) {
        return redirect('/');
    }
}

With this feature I can simply add an option:

No need to create a new middleware.

// pages/guest.vue
<template>
  <div>guest</div>
</tempalte>

<script>
export default {
  middleware: ['auth'],
  options: {
    auth: 'guest'
  }
}
</script>

@ricardogobbosouza ricardogobbosouza changed the title feat(middleware): add guest option in auth middleware feat(middleware): add guest option in auth middleware Nov 5, 2018
@ricardogobbosouza
Copy link
Member Author

@pi0 @Atinux any chance you could take a look at this PR? Thanks!

@pi0
Copy link
Member

pi0 commented May 23, 2019

Nice feature @ricardogobbosouza :) Thanks!

@pi0 pi0 merged commit 54b0720 into nuxt-community:dev May 23, 2019
@pi0 pi0 mentioned this pull request May 23, 2019
@pi0
Copy link
Member

pi0 commented May 30, 2019

This PR has been published in v4.6.0

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.

None yet

2 participants