laravel - 使用Vue Js和Laravel提交身份验证后如何修复localhost:8000提示登录
问题描述
登录后我的身份验证出现问题,提示 localhost:8000 登录或登录,这是我第一次遇到这种情况,我不知道这叫什么,我没有找到任何参考。目前我在后端使用 laravel,前端使用 vue js。所以这个项目是由老开发者创建的。所以现在我需要修改那里项目的一些模块,但是我在系统上登录显示这个提示。请注意,该项目当前正在运行,并且在我登录时没有错误并提示登录。
这是我登录后显示的提示标志。
配置:
- Laravel 护照
- Vuex 状态管理
- Vue Js
方法:
methods:{
authenticate(){
this.login_alert = false
this.$validator.validateAll().then((result)=>{
if(result){
const self = this;
const authUser = {}
try{
const data = {
username: this.email,
password: this.password,
remember: this.remember_me,
client_id: '2',
client_secret: 'just secret only',
grant_type : 'password',
scope : ''
}
this.$store.dispatch('AUTH_REQUEST',data)
.then(response=>{
authUser.access_token = response.access_token
authUser.refresh_token = response.refresh_token
authUser.expires_in = response.expires_in
window.localStorage.setItem('project_token',JSON.stringify(authUser))
/*LOGIN*/
this.login_alert = false
this.loading = false
window.location.reload()
})
.catch(error=>{
this.login_alert = true
window.localStorage.removeItem('project_token')
this.loading = false
})
}catch(err){
console.log(err);
}
}
})
}
},
授权请求:
AUTH_REQUEST:({commit,dispatch},obj)=>{
return new Promise((resolve,reject) => {
axios({
url: '/oauth/token',
data: obj,
method:'post',
config:'JSON'
})
.then(response=>{
if(response.status == 200){
resolve(response.data);
}
})
.catch(error=>{
reject(error);
localStorage.removeItem('project_token');
commit('AUTH_ERROR',error);
})
})
},
希望有人可以帮助我解决这个问题。谢谢你。
解决方案
推荐阅读
- c# - 如何使用 linq 找到存在特定字符串的列表?
- docker - Docker 导致“以非零退出代码退出的命令之一;请注意,snakemake 使用 bash 严格模式!” 与蛇人
- python - 如何解释这种类型的树状图?
- php - 如何仅替换 PHP 中字符串末尾的特定单词?
- swift - 如何找出编码路径中的哪个元素导致 Swift Decoding 错误?
- javascript - 将带有 fetch 的 POST 发送到烧瓶时的端口问题
- r - 在 R 中读取和过滤具有不同列数的 .DAT 文件
- sorting - Woocommerce - 如何将已售和隐藏的产品分类到目录末尾?
- delphi - 如何在没有所有浏览器历史记录的情况下保持登录浏览器 CEF4Delphi?
- node.js - NodeJS中的标准输出管道