vue-auth
vue-auth copied to clipboard
Built in cookie store broken in latest version?
Using 4.1.7 version with v2, and this is setup:
import Vue from "vue";
import auth from "@websanova/vue-auth/dist/v2/vue-auth.common.js";
import driverAuthBearer from "@websanova/vue-auth/dist/drivers/auth/bearer.js";
import driverHttpVueResource from "@websanova/vue-auth/dist/drivers/http/vue-resource.1.x.js";
import driverRouterVueRouter from "@websanova/vue-auth/dist/drivers/router/vue-router.2.x.js";
Vue.use(auth, {
plugins: {
http: Vue.http,
router: Vue.router,
},
drivers: {
auth: driverAuthBearer,
http: driverHttpVueResource,
router: driverRouterVueRouter,
},
options: {
rememberkey: "auth_remember",
tokenDefaultKey: "auth_token_default",
tokenImpersonateKey: "auth_token_impersonate",
stores: ["cookie", "storage"],
},
});
And login simply does:
this.$auth
.login({
body: {
email: "",
password: "",
},
staySignedIn: true,
})
.then(...);
When the stores
is set to ["cookie", "storage"]
the login() does its job and fetch back correct jwt but doesn't store the token in either cookie or localStorage, then the user fetch fails because the request is missing the Authoriziation
header.
If I change the stores
to ["storage", "cookie"]
or just remove stores
option entirely, then it works fine.
I got same issue but only when origins are not same.
I think it because browsers changed their cookie policies.
I had the same issue, I did a lot of workarounds but tokens still don't persist in both local storage and cookies, I tried to set cookies from my side in the login request before fetching the user but I couldn't, now I had an Unauthorized error for /user and the login is correctly passed, but due to cookies storage issue, the user data fetching didn't work properly.
In another nuxt project, I'm using nuxt-auth package and cookies work properly, i.e I don't think that it's a cookie policies @zorn-v.
does anyone know how to inherit the driver properly(to avoid implementing the driver into node_modules), and set cookies on my own using vue-cookie package. I tried to set cookies from the node_modules folder of vue-auth, but I couldn't use vue-cookie for that.
@BennaceurHichem Hard to say, Did you try any tests independent of the library with just raw JS?