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

401 error when using cookies and not token #550

Closed
radudiaconu0 opened this issue Mar 10, 2020 · 11 comments
Closed

401 error when using cookies and not token #550

radudiaconu0 opened this issue Mar 10, 2020 · 11 comments

Comments

@radudiaconu0
Copy link

radudiaconu0 commented Mar 10, 2020

WHen i use laravel airlock with nuxt js and auth module on every page i navigate i get 401 error without being authenticated. i put correct middleware on every route. why is that happen? when i login all things works properly.(i use spa mode but i am curious how can i make things works on unversal mode)
this is my nuxt configuration:

axios: { baseURL: 'http://app.cheer.test/', withCredentials: true }, auth: { redirect: { login: '/login', logout: '/', callback: '/login', home: '/home' }, strategies: { local: { endpoints: { login: { url: 'login', method: 'post', withCredentials: true, headers: { 'X-Requested-With': 'XMLHttpRequest', 'Content-Type': 'application/json' } }, logout: { url: 'logout', method: 'post', withCredentials: true, }, user: { url: '/api/user', method: 'get', propertyName: 'user', withCredentials: true, headers: { 'X-Requested-With': 'XMLHttpRequest', 'Content-Type': 'application/json' } }, home: '/home' }, tokenRequired: false, tokenType: false } } },

@AndrewSavetchuk
Copy link

Same here!
Nuxt auth for some reason tries to fetch user when I'm browsing the website as a guest 🤔

Here's my config:
Screen Shot 2020-03-13 at 3 05 12 AM

@tiran133
Copy link

Have a look at this might help you with the solution
https://serversideup.net/using-laravel-airlock-with-nuxtjs/

@dloused
Copy link

dloused commented Mar 22, 2020

same here...

Nuxt auth for some reason tries to fetch user when I'm browsing the website as a guest 🤔

@bruceparish
Copy link

I'm having the same issue as well. There has to be a better way to see if user is logged in on cookie flow that doesn't involve getting a 401 from the user endpoint. And with the user endpoint set to false, you're always logged in. Seems like getting the logged in status in general for the cookie flow is a little off.

@ryzexsp
Copy link

ryzexsp commented Apr 7, 2020

same here ...

any solution ?

======

set user to false and get user manually

  axios: {
    baseURL: 'http://127.0.0.1:8000',
    credentials : true
  },


  auth: {
    strategies: {
      local: {
        endpoints: {
          login: {
            url: '/login',
            method: 'post',
          },
          user: false
        },
        tokenRequired: false,
        tokenType: false
      }
    }
  },

@pawel-marciniak
Copy link

Same issue here... Can this be even fixed?

@planetchili
Copy link

Yeah, it seems pretty broken. Glad it's not just me. Disabling the feature altogether and grabbing that data manually seems like a viable workaround at least.

@JoaoPedroAS51
Copy link
Collaborator

JoaoPedroAS51 commented Dec 18, 2020

Closing here, as cookie scheme and laravel sanctum provider are now available in auth v5.

@GanchoDanailov
Copy link

any update on this?

@JoaoPedroAS51
Copy link
Collaborator

@GanchoDanailov @planetchili @pawel-marciniak @ryzexsp @brcpar @dloused @tiran133 @AndrewSavetchuk

Hey guys! This issue was already fixed :)

You should use cookie scheme, which depends on cookie instead of token. And if you are using laravel sanctum, then I recommend the laravel sanctum provider.

Both are available in auth v5. We now recommend using v5 instead of v4. See status and #893

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 a pull request may close this issue.

11 participants