Auth-module: nuxt auth always redirecting to login

Created on 10 May 2019  Â·  9Comments  Â·  Source: nuxt-community/auth-module

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

All 9 comments

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.

Same here…

yep same

Same

Same

Same

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>

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'
    }

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

Was this page helpful?
0 / 5 - 0 ratings