auth-module icon indicating copy to clipboard operation
auth-module copied to clipboard

"user" endpoint is called even when login has error

Open M-Barari opened this issue 2 years ago • 0 comments

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!!

M-Barari avatar Jun 18 '22 08:06 M-Barari