nuxt-community / laravel-echo-module

Laravel Echo for Nuxt 2
MIT License
85 stars 32 forks source link

Invalid token receipt when used with @nuxtjs/auth-next #24

Closed Icon003 closed 3 years ago

Icon003 commented 4 years ago

Hello, when using @nuxtjs/auth-next, getting a token does not work. To make this work, you need to make changes to laravel-echo/lib/plugin.js on line 16.

Replace const token = app.$auth.getToken(strategy.name) with const token = app.$auth.token.get(strategy.name)

esbol-moldrakhmetov commented 4 years ago

@Icon003 Hi, If you have found a solution, please tell me, I also faced the same problem?

need cherry-pick this commit https://github.com/esbol-moldrakhmetov/laravel-echo/commit/55c955114739a11e1709308d18faa3d84231a4c7

Icon003 commented 4 years ago

@esbol-moldrakhmetov Hello, you can use my fork https://github.com/Icon003/laravel-echo/tree/feat/auth-v5

Icon003 commented 4 years ago

@esbol-moldrakhmetov Or replace the line I'm talking about with, const token = app.$auth.strategy.token.get() Now again in a different way

brgmn commented 3 years ago

@ricardogobbosouza Hey, I just forked the plugin to be compatible with nuxtjs/auth-next, too. Maybe you could add a small auth-next branch here or (better) a plugin config option for enabling auth-next.

osster commented 3 years ago

Hello, when using @nuxtjs/auth-next, getting a token does not work. To make this work, you need to make changes to laravel-echo/lib/plugin.js on line 16.

Replace const token = app.$auth.getToken(strategy.name) with const token = app.$auth.token.get(strategy.name)

Laravel Sanctum + @nuxt/auth-next

...till couple days auth is working... not the best way, but working for me.

~nuxt.config.js

auth: { ... plugins: [ { src: '~/plugins/auth.js', ssr: false } ] }

~plugins/auth.js

import * as Cookies from 'js-cookie' export default function ({ $auth }) { // Set name & Function == Hack it anyway $auth.strategy.options.tokenName = 'X-XSRF-TOKEN' $auth.getToken = (name) => { return Cookies.get('XSRF-TOKEN') || '' } }

ricardogobbosouza commented 3 years ago

Try alpha version 2.0.0-alpha.0

franck-grenier commented 2 years ago

Hello Nuxt Community, are you planning to release a stable v2.0.0 of laravel-echo-module compatible with @nuxtjs/auth-next ?