文章出處
文章列表
IdentityServer4 退出登錄后,默認會跳轉到Config.Client
配置的PostLogoutRedirectUris
地址,那我們如何動態的跳轉到原來的地址呢?實現很簡單,Logout
修改如下:
[HttpGet]
public async Task<IActionResult> Logout(string logoutId)
{
var logout = await _interaction.GetLogoutContextAsync(logoutId);
await HttpContext.Authentication.SignOutAsync();
if (logout.PostLogoutRedirectUri != null)
{
return Redirect(logout.PostLogoutRedirectUri);
}
var refererUrl = Request.Headers["Referer"].ToString();
return Redirect(refererUrl);
}
授權中心刪除PostLogoutRedirectUris
配置:
new Client
{
ClientId = "h5",
//PostLogoutRedirectUris = { "http://localhost:5003/index.html" }
//...
}
前端項目刪除post_logout_redirect_uri
配置:
var config = {
authority: "http://localhost:5001",
//post_logout_redirect_uri: "http://localhost:5003/index.html",
//...
};
文章列表
全站熱搜