nuxt-community / auth-module

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

"user" endpoint is called even when login has error #1767

Open M-Barari opened 2 years ago

M-Barari commented 2 years ago

Hi, I'm using "nuxt": "^2.15.8" with "@nuxtjs/auth": "^4.9.1" . and my auth config in nuxt.config.js is like this:

auth: {
    strategies: {
      local: {
        endpoints: {
          login: { url: 'v1/auth/login', method: 'post', propertyName: 'token' },
          logout: { url: 'v1/auth/logout', method: 'post' },
          user: { url: 'v1/auth/user', method: 'get', propertyName: 'data' }
        }
      }
    },
    redirect: {
      login: '/auth/signin',
      home: '',
      logout: '/auth/signin'
      // callback: '/auth/signin',
    },
    cookie: {
      prefix: 'auth.',
      options: {
        path: '/',
        maxAge: process.env.AUTH_COOKIE_MAX_AGE
      }
    }
  },

I had this setup in another project and it's working fine, but in my new project when I call:

try {
      let res = await this.$auth.loginWith('local',{ data: formData })
      return res
  }catch(e){
      console.log(e)
  }

even when I have errors such as 401,411,438,.... it still won't go to catch and send fetchUser call too!!