Closed shakhawatfci closed 3 years ago
Could you post a repro, or at least more details on what "not working" means?
Could you post a repro, or at least more details on what "not working" means?
token and user information which is coming from backend not getting stored at vuex , localstorage . or not even in cookies if i set it manually it's getting disappear after page change
I don't have your code running and so can only be of limited help - you'll need to be even more specific. Is the information getting returned by the backend? Is it ever getting set by auth? When, exactly, does it go away? Have you searched for other issues in this repo that might match what you're encountering?
Data returning from backend in this format
{
"status": "success",
"token": "MySecret-Token",
"user": {
"id": 1002,
"name": "Shakhwat hossain",
"avatar": "https:someimageapi.com/avatar.jpg",
"mobile_no": "01834394****",
"email": "shakhawat@limmexbd.com",
"area_id": 1,
"sub_area_id": 0,
}
after loginwith method resolved i am trying to redirect user to /dashboard but it redirecting back to login page because login no getting set .
here is response after hit to api
here is the condition of cookie
and vuex state
i don't know the newest version of auth-module compatible with this version of nuxt
"dependencies": {
"@bachdgvn/vue-otp-input": "^1.0.8",
"@nuxtjs/auth-next": "^5.0.0-1608461079.ae1e5db",
"@nuxtjs/axios": "^5.12.4",
"bootstrap": "^4.5.2",
"bootstrap-vue": "^2.17.3",
"cookieparser": "^0.1.0",
"core-js": "^3.6.5",
"js-cookie": "^2.2.1",
"nuxt": "^2.14.6"
},
Hi @shakhawatfci, same problem here,with same auth-next and nuxt version. After reading your thread, I resolved the probleme with this configuration in nuxt.config.js:
local: {
token: {
property: 'access_token', // as my backend send access_token instead of token
required: true,
type: 'Bearer',
},
endpoints: {
login: { url: 'login', method: 'post' },
user: { url: 'me', method: 'get', property: 'user' },
logout: false,
},
Hope this helps...
I solved the problem by set manually user and token as below in login method
async login() {
try {
let response = await this.$auth.loginWith("local", { data: this.form });
this.$auth.setUserToken(response.data.token);
this.$auth.setUser(response.data.user);
} catch (err) {
console.log(err.response.data.message);
}
},
Hi @shakhawatfci ! I'm happy to know that it's working now! :)
I just would suggest to set token.required
to true
in your config, so you don't need to manually set the token after login.
Hi @shakhawatfci ! I'm happy to know that it's working now! :)
I just would suggest to set
token.required
totrue
in your config, so you don't need to manually set the token after login.
Thanks it works .
I have laravel passport based api where i am requesting from my nuxt app with login data and data responding in below format
{ "status": "success", "token": "MySecret-Token", "user": { "id": 1002, "name": "Shakhwat hossain", "avatar": "https:someimageapi.com/avatar.jpg", "mobile_no": "01834394****", "email": "shakhawat@limmexbd.com", "area_id": 1, "sub_area_id": 0, }
but login not working in nuxt application using nuxt-auth module version 5.0.0-1608140074.47635f0
here is my login method
and here is my nuxt auth setting in nuxt.config.js