我正在尝试在react中实现OpenId和oidc-客户端js。现在我被困在实现注销函数上了。
据我所知,我需要设置post_logout_redirect_uri并使用signoutRedirect()注销用户。注销用户可以工作,但不幸的是,它停留在标识服务器注销页面中。我需要做的是将用户重定向到post_logout_redirect_uri。
有人能告诉我我在这里错过了什么吗?提前感谢!
这是我被重定向的URL。https://identityserver.xx.com/Account/Logout?logoutId=CfDJ8Cqm6alCoddAqWl...
,这是我的技术栈:
下面的是我的身份服务器管理设置.
,这是注销代码
logout = async () => {
try {
userManager.signoutRedirect({
id_token_hint: this.user?.id_token,
post_logout_redirect_uri : process.env.REACT_APP_LOGOFF_REDIRECT_URL,
state: this.user?.state
}).then( () => {
console.log('done signoutRedirect')
});
userManager.clearStaleState()
}catch(error){
console.log(error);
}
}发布于 2021-10-21 01:34:40
在AccountController -> BuildLoggedOutViewModelAsync方法中,在构造视图模型时检查AutomaticRedirectAfterSignOut是正确的。
var vm = new LoggedOutViewModel
{
AutomaticRedirectAfterSignOut = AccountOptions.AutomaticRedirectAfterSignOut, //this must return true.
PostLogoutRedirectUri = logout?.PostLogoutRedirectUri,
ClientName = string.IsNullOrEmpty(logout?.ClientName) ? logout?.ClientId : logout?.ClientName,
SignOutIframeUrl = logout?.SignOutIFrameUrl,
LogoutId = logoutId
};在您看来,LoggedOut.cshtml检查~/js/signout-redirect.js是正确的。
@section scripts
{
@if (Model.AutomaticRedirectAfterSignOut)
{
<script src="~/js/signout-redirect.js"></script>
}
}如果您的注销页面不包含带有<a id="post-logout-redirect-uri" ...>的锚标记,那么很可能在请求和客户端中配置了不匹配的post_logout_redirect_uri。
https://stackoverflow.com/questions/69654687
复制相似问题