如何解决OKta + Vue:从按钮调用时,或从 vue 页面创建事件调用时,Okta 注销代码的行为不同
我正在编写一个 vue 应用程序,打字稿使用 Okta 处理身份验证。
App.vue 中有一个按钮,用于调用 okta 注销方法,然后重定向到登录页面。
methods: {
<snip>
logout()
{
this.$auth.logout()// this code is still called on the login path,but if logout fails,it gets stuck in a loop,so we need it here too,despite the inelegance - EWB
this.$router.push('/login')
},},
在登录页面的创建事件中,它调用注销,然后清除商店中的用户。 我希望能够通过重定向到登录页面来注销,这将强制注销任何陈旧的用户,因为 Okta 登录生命周期取决于 chrome 设置,以确定它是否会持续通过关闭的浏览器(在后台继续运行应用程序)。
created() {
// Log out
this.$auth.logout().catch((e) => alert(`Logout Error: ${e}`))
this.$store.dispatch('clearUserInfo')
},
如果我在按钮上有注销调用,注销工作,但如果我不这样做,它会失败,这会导致无限循环(作为登录页面上的错误)
撤销调用失败消息 {"errorCode":"E0000022","errorSummary":"端点不支持提供的 HTTP 方法","errorLink":"E0000022","errorId":"oaefNQXkh7xSlKg9KpeoMa62A","errorCauses":[]}>
然后循环不断调用获取用户数据https://jobcorps.oktapreview.com/api/v1/sessions/meA
用户没有登出,所以返回好的数据。
{"id":"102UHL9iAB7TFyEs0LAndwXjw","userId":"00ugglloxMSMMMbhI1d6","login":"Kameroff.Danielle@live.jobcorps.dev","createdAt":"2021-07-09T31020 Z","expiresAt":"2021-07-10T00:05:09.000Z","status":"ACTIVE","lastPasswordVerification":"2021-07-09T21:26:31.000Z","lastFactorVerification":null,"amr":["pwd"],"idp":{"id":"0oaggk2b9CG7Mq9N31d6","type":"ACTIVE_DIRECTORY"},"mfaActive":false,"_links":{"self":{" href":"https://jobcorps.oktapreview.com/api/v1/sessions/me","hints":{"allow":["GET","DELETE"]}},"refresh":{" href":"https://jobcorps.oktapreview.com/api/v1/sessions/me/lifecycle/refresh","hints":{"allow":["POST"]}},"user":{" name":"Kameroff,Danielle - 阿拉斯加学生","href":"https://jobcorps.oktapreview.com/api/v1/users/me","hints":{"allow":["GET"] }}}}
为什么以 2 种不同方式调用时代码的行为如此不同?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。