nuxt-community / auth-module

Zero-boilerplate authentication support for Nuxt 2
https://auth.nuxtjs.org
MIT License
1.93k stars 925 forks source link

nuxt auth always redirecting to login #347

Closed nitinsinghnaruka closed 5 years ago

nitinsinghnaruka commented 5 years ago

auth: { strategies: { local: { endpoints: { login: { url: '/login', method: 'post', propertyName: false }, logout: { url: '/logout', method: 'post' }, user: { url: '/user', method: 'get', propertyName: false } }, // tokenRequired: true, // tokenType: 'Bearer', // Case sensitive when dealing with Laravel backend. } }, redirect: { login: '/login', logout: '/', callback: '/login', home: '/dashboard' } },

router: { middleware: ['auth'] },

dashboard page export default { name: 'dashboard', layout: 'dashboard', }

This question is available on Nuxt community (#c326)
ghost commented 5 years ago

This issue as been imported as question since it does not respect auth-module issue template. Only bug reports and feature requests stays open to reduce maintainers workload. If your issue is not a question, please mention the repo admin or moderator to change its type and it will be re-opened automatically. Your question is available at https://cmty.app/nuxt/auth-module/issues/c326.

noelboss commented 5 years ago

Same here…

ewen-lbh commented 5 years ago

yep same

paulvonber commented 5 years ago

Same

blackfyre commented 5 years ago

Same

diguliu commented 5 years ago

Same

StefKors commented 5 years ago

for me my template was this: <button @click="login()">Login with Google</button> adding .prevent solved it <button @click.prevent="login()">Login with Google</button>

przemyslaw-przylucki commented 5 years ago

For people using Laravel Passport and basic /user route in api.php, you need to specify propertyName in strategy like this, also remember to have correct route prefix.

strategies: {
      local: {
        endpoints: {
          login: {
            url: 'api/login',
            method: 'post',
            propertyName: 'access_token'
          },
          user: { url: 'api/user', method: 'get', propertyName: false } //here
        },
        tokenType: 'Bearer',
        tokenRequired: true
      }
    },
    redirect: {
      login: '/login',
      logout: '/login',
      home: '/dashboard',
      user: '/dashboard'
    }
tsega commented 4 years ago

I think my issue was related to not specifying all the properties of the redirect key.