Browse Source

Save the client id for Authorization Code Grant.

Resolve #7274
pull/7297/head
maliming 6 years ago
parent
commit
c3ba4b637a
  1. 5
      modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLoginModel.cs
  2. 23
      modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLogoutModel.cs

5
modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLoginModel.cs

@ -103,9 +103,9 @@ namespace Volo.Abp.Account.Web.Pages.Account
public override async Task<IActionResult> OnPostAsync(string action)
{
var context = await Interaction.GetAuthorizationContextAsync(ReturnUrl);
if (action == "Cancel")
{
var context = await Interaction.GetAuthorizationContextAsync(ReturnUrl);
if (context == null)
{
return Redirect("~/");
@ -142,7 +142,8 @@ namespace Volo.Abp.Account.Web.Pages.Account
{
Identity = IdentitySecurityLogIdentityConsts.Identity,
Action = result.ToIdentitySecurityLogAction(),
UserName = LoginInput.UserNameOrEmailAddress
UserName = LoginInput.UserNameOrEmailAddress,
ClientId = context?.Client?.ClientId
});
if (result.RequiresTwoFactor)

23
modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLogoutModel.cs

@ -20,12 +20,6 @@ namespace Volo.Abp.Account.Web.Pages.Account
public async override Task<IActionResult> OnGetAsync()
{
await IdentitySecurityLogManager.SaveAsync(new IdentitySecurityLogContext()
{
Identity = IdentitySecurityLogIdentityConsts.Identity,
Action = IdentitySecurityLogActionConsts.Logout
});
await SignInManager.SignOutAsync();
var logoutId = Request.Query["logoutId"].ToString();
@ -33,11 +27,14 @@ namespace Volo.Abp.Account.Web.Pages.Account
if (!string.IsNullOrEmpty(logoutId))
{
var logoutContext = await Interaction.GetLogoutContextAsync(logoutId);
await SaveSecurityLogAsync(logoutContext?.ClientId);
await SignInManager.SignOutAsync();
HttpContext.User = new ClaimsPrincipal(new ClaimsIdentity());
LoggedOutModel vm = new LoggedOutModel()
var vm = new LoggedOutModel()
{
PostLogoutRedirectUri = logoutContext?.PostLogoutRedirectUri,
ClientName = logoutContext?.ClientName,
@ -49,6 +46,8 @@ namespace Volo.Abp.Account.Web.Pages.Account
return RedirectToPage("./LoggedOut", vm);
}
await SaveSecurityLogAsync();
if (ReturnUrl != null)
{
return LocalRedirect(ReturnUrl);
@ -58,5 +57,15 @@ namespace Volo.Abp.Account.Web.Pages.Account
$"IdentityServerSupportedLogoutModel couldn't find postLogoutUri... Redirecting to:/Account/Login..");
return RedirectToPage("/Account/Login");
}
protected virtual async Task SaveSecurityLogAsync(string clientId = null)
{
await IdentitySecurityLogManager.SaveAsync(new IdentitySecurityLogContext()
{
Identity = IdentitySecurityLogIdentityConsts.Identity,
Action = IdentitySecurityLogActionConsts.Logout,
ClientId = clientId
});
}
}
}

Loading…
Cancel
Save