文章出處

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",
    //...
};

文章列表




Avast logo

Avast 防毒軟體已檢查此封電子郵件的病毒。
www.avast.com


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()