Browse Source

Merge pull request #22097 from abpframework/auto-merge/rel-9-1/3461

Merge branch dev with rel-9.1
pull/22119/head
maliming 1 year ago
committed by GitHub
parent
commit
7b293c31b2
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 30
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AspNetIdentity/AbpResourceOwnerPasswordValidator.cs
  2. 34
      modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/TokenController.Password.cs

30
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AspNetIdentity/AbpResourceOwnerPasswordValidator.cs

@ -128,21 +128,29 @@ public class AbpResourceOwnerPasswordValidator : IResourceOwnerPasswordValidator
} }
else if (result.IsNotAllowed) else if (result.IsNotAllowed)
{ {
Logger.LogInformation("Authentication failed for username: {username}, reason: not allowed", context.UserName); if (!await UserManager.CheckPasswordAsync(user, context.Password))
if (user.ShouldChangePasswordOnNextLogin)
{ {
await HandleShouldChangePasswordOnNextLoginAsync(context, user, context.Password); Logger.LogInformation("Authentication failed for username: {username}, reason: invalid credentials", context.UserName);
return; errorDescription = Localizer["InvalidUserNameOrPassword"];
} }
else
if (await UserManager.ShouldPeriodicallyChangePasswordAsync(user))
{ {
await HandlePeriodicallyChangePasswordAsync(context, user, context.Password); Logger.LogInformation("Authentication failed for username: {username}, reason: not allowed", context.UserName);
return;
}
errorDescription = Localizer["LoginIsNotAllowed"]; if (user.ShouldChangePasswordOnNextLogin)
{
await HandleShouldChangePasswordOnNextLoginAsync(context, user, context.Password);
return;
}
if (await UserManager.ShouldPeriodicallyChangePasswordAsync(user))
{
await HandlePeriodicallyChangePasswordAsync(context, user, context.Password);
return;
}
errorDescription = Localizer["LoginIsNotAllowed"];
}
} }
else else
{ {

34
modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/TokenController.Password.cs

@ -115,24 +115,32 @@ public partial class TokenController
} }
else if (result.IsNotAllowed) else if (result.IsNotAllowed)
{ {
Logger.LogInformation("Authentication failed for username: {username}, reason: not allowed", request.Username); if (!await UserManager.CheckPasswordAsync(user, request.Password))
if (user.ShouldChangePasswordOnNextLogin)
{ {
return await HandleShouldChangePasswordOnNextLoginAsync(request, user, request.Password); Logger.LogInformation("Authentication failed for username: {username}, reason: invalid credentials", request.Username);
errorDescription = "Invalid username or password!";
} }
else
if (await UserManager.ShouldPeriodicallyChangePasswordAsync(user))
{ {
return await HandlePeriodicallyChangePasswordAsync(request, user, request.Password); Logger.LogInformation("Authentication failed for username: {username}, reason: not allowed", request.Username);
}
if (user.IsActive) if (user.ShouldChangePasswordOnNextLogin)
{ {
return await HandleConfirmUserAsync(request, user); return await HandleShouldChangePasswordOnNextLoginAsync(request, user, request.Password);
} }
errorDescription = "You are not allowed to login! Your account is inactive."; if (await UserManager.ShouldPeriodicallyChangePasswordAsync(user))
{
return await HandlePeriodicallyChangePasswordAsync(request, user, request.Password);
}
if (user.IsActive)
{
return await HandleConfirmUserAsync(request, user);
}
errorDescription = "You are not allowed to login! Your account is inactive.";
}
} }
else else
{ {

Loading…
Cancel
Save