使用VUE 2和插件vue-auth (https://github.com/websanova)。由于任何原因,在IE和边缘中,auth令牌被从页面刷新的localStorage中删除,但是在Chrome中,FF所有的东西都正常工作,令牌也没有被删除。
我一直在开发铬和即将推出的产品。在其他浏览器上进行测试,然后在开发阶段接近尾声时受到了攻击。使用他们的文档,我基本上是设置它,没有任何真正的改变。
Vue.use(require('@websanova/vue-auth'), {
auth: require('@websanova/vue-auth/drivers/auth/bearer.js'),
http: require('@websanova/vue-auth/drivers/http/axios.1.x.js'),
router: require('@websanova/vue-auth/drivers/router/vue-router.2.x.js'),
refreshData: {enabled: false},
});
Vue.auth.login({
method: 'post',
data: {email: payload.email, password: payload.password, rememberMe: true},
}).catch(error => {
console.log('error happened');
console.log(error);
})打开IE,转到页面,登录,查看localStorage default_auth_token。点击F5用户将被注销。Vuew localStorage和default_auth_token走了。
在IE中完全一样。
我不做任何自定义与他们的插件其他,然后禁用折光令牌选项,因为我们不使用他们。
我知道这可能是一个很长的机会,在这里寻找一个修复,但我已经尝试使用github问题(https://github.com/websanova/vue-auth/issues/309),但没有任何效果。
发布于 2018-02-15 21:36:54
I…恨…IE…
如果cookie有一个localhost域(没有三个点域,比如foo.bar.com),那么IE和Edge就让它通过而不会出错。Cookie没有被保存,您也不知道为什么。
function setCookie (name, value, timeOffset) {
var domain = this.options.cookieDomain();
var expires = (new Date((new Date()).getTime() + timeOffset)).toUTCString();
if (domain === 'localhost'){
document.cookie = name + '=' + value + '; Expires=' + expires + ';Path=/;';
} else {
document.cookie = name + '=' + value + '; Expires=' + expires + ';Path=/; Domain=' + domain + ';';
}
}这花了我一整天的时间来追踪这个插件,但现在我真正明白了它是如何工作的。我通常是后端python开发人员,所以这很有启发性。
https://stackoverflow.com/questions/48810643
复制相似问题