Browse Source
Merge pull request #13843 from roc916/openiddict
fix `User.IsActive` and `IsLockedOut` is invalid when authorization
pull/13851/head
maliming
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
23 additions and
3 deletions
-
modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/AbpOpenIdDictControllerBase.cs
-
modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/TokenController.AuthorizationCode.cs
-
modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/TokenController.DeviceCode.cs
-
modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/TokenController.RefreshToken.cs
|
|
|
@ -73,4 +73,24 @@ public abstract class AbpOpenIdDictControllerBase : AbpController |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual async Task<bool> PreSignInCheckAsync(IdentityUser user) |
|
|
|
{ |
|
|
|
if (!user.IsActive) |
|
|
|
{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
if (!await SignInManager.CanSignInAsync(user)) |
|
|
|
{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
if (await UserManager.IsLockedOutAsync(user)) |
|
|
|
{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -33,7 +33,7 @@ public partial class TokenController |
|
|
|
} |
|
|
|
|
|
|
|
// Ensure the user is still allowed to sign in.
|
|
|
|
if (!await SignInManager.CanSignInAsync(user)) |
|
|
|
if (!await PreSignInCheckAsync(user)) |
|
|
|
{ |
|
|
|
return Forbid( |
|
|
|
authenticationSchemes: OpenIddictServerAspNetCoreDefaults.AuthenticationScheme, |
|
|
|
|
|
|
|
@ -33,7 +33,7 @@ public partial class TokenController |
|
|
|
} |
|
|
|
|
|
|
|
// Ensure the user is still allowed to sign in.
|
|
|
|
if (!await SignInManager.CanSignInAsync(user)) |
|
|
|
if (!await PreSignInCheckAsync(user)) |
|
|
|
{ |
|
|
|
return Forbid( |
|
|
|
authenticationSchemes: OpenIddictServerAspNetCoreDefaults.AuthenticationScheme, |
|
|
|
|
|
|
|
@ -33,7 +33,7 @@ public partial class TokenController |
|
|
|
} |
|
|
|
|
|
|
|
// Ensure the user is still allowed to sign in.
|
|
|
|
if (!await SignInManager.CanSignInAsync(user)) |
|
|
|
if (!await PreSignInCheckAsync(user)) |
|
|
|
{ |
|
|
|
return Forbid( |
|
|
|
authenticationSchemes: OpenIddictServerAspNetCoreDefaults.AuthenticationScheme, |
|
|
|
|