Angular 7 - Auth0 - parseHash 响应为空
Angular 7 - Auth0 - parseHash response null
Auth0 问题。
我的应用程序在浏览器刷新时注销后重新触发登录事件,并且用户配置文件存在问题。我在身份验证服务中追踪到 parseHash:
this.auth0.parseHash({ hash: window.location.hash }, (err, authResult) => {
...
}
使用 ngrx 效果触发:
@Effect()
init$ = defer(() => {
const userData = localStorage.getItem("user");
if (userData != null && userData != 'undefined') {
let authActionObservable = of(new Login({user: JSON.parse(userData)}));
this.authService.handleAuthentication();
return authActionObservable;
}
this.authService.handleAuthentication();
});
似乎是这样。auth0.parseHash 在页面刷新后为 authResult 和 err 返回 null,但在初始登录时 authResult 被正确填充。
技术上登录成功,我得到了令牌。我检查了整个配置、域等,一切似乎都很好。我也试过玩弄 { hash: window.location.hash }.
我经常看到 HAR 文件被捕获以帮助缩小注销工作流程期间发生的事情的准确范围。没有确切地看到有几件事我可以建议看一看。
- 查看 Logout Documentation
- 在 how to handle Redirects after logout 上查看此文档并评估您如何处理注销。
- 您需要确保将 client_id 参数传递给注销端点,同时在客户端级别设置允许注销 URL。
现在我可能在这里发生的事情的核心是错误的,但即兴的是一个很好的基本起点。谢谢!
问题在于,包含服务令牌的 in-memory 变量的状态在每次页面刷新时都会被重置。一旦我 re-initialized 服务构造函数中的值,问题就消失了。
这里用 localStorage 举例说明我的意思:
constructor(public router: Router, private store: Store<State>, private http: HttpClient) {
this._idToken = localStorage.getItem("Auth0IdToken");
this._accessToken = localStorage.getItem("Auth0AccessToken");
this._expiresAt = parseInt(localStorage.getItem("Auth0ExpiresAt"));
}
Auth0 问题。
我的应用程序在浏览器刷新时注销后重新触发登录事件,并且用户配置文件存在问题。我在身份验证服务中追踪到 parseHash:
this.auth0.parseHash({ hash: window.location.hash }, (err, authResult) => {
...
}
使用 ngrx 效果触发:
@Effect()
init$ = defer(() => {
const userData = localStorage.getItem("user");
if (userData != null && userData != 'undefined') {
let authActionObservable = of(new Login({user: JSON.parse(userData)}));
this.authService.handleAuthentication();
return authActionObservable;
}
this.authService.handleAuthentication();
});
似乎是这样。auth0.parseHash 在页面刷新后为 authResult 和 err 返回 null,但在初始登录时 authResult 被正确填充。
技术上登录成功,我得到了令牌。我检查了整个配置、域等,一切似乎都很好。我也试过玩弄 { hash: window.location.hash }.
我经常看到 HAR 文件被捕获以帮助缩小注销工作流程期间发生的事情的准确范围。没有确切地看到有几件事我可以建议看一看。
- 查看 Logout Documentation
- 在 how to handle Redirects after logout 上查看此文档并评估您如何处理注销。
- 您需要确保将 client_id 参数传递给注销端点,同时在客户端级别设置允许注销 URL。
现在我可能在这里发生的事情的核心是错误的,但即兴的是一个很好的基本起点。谢谢!
问题在于,包含服务令牌的 in-memory 变量的状态在每次页面刷新时都会被重置。一旦我 re-initialized 服务构造函数中的值,问题就消失了。
这里用 localStorage 举例说明我的意思:
constructor(public router: Router, private store: Store<State>, private http: HttpClient) {
this._idToken = localStorage.getItem("Auth0IdToken");
this._accessToken = localStorage.getItem("Auth0AccessToken");
this._expiresAt = parseInt(localStorage.getItem("Auth0ExpiresAt"));
}