diff --git a/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpSignInManager.cs b/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpSignInManager.cs index bbba6e63ec..42ef9e5261 100644 --- a/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpSignInManager.cs +++ b/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpSignInManager.cs @@ -85,6 +85,12 @@ public class AbpSignInManager : SignInManager return SignInResult.NotAllowed; } + if (user.ShouldChangePasswordOnNextLogin) + { + Logger.LogWarning($"The user should change password! (username: \"{user.UserName}\", id:\"{user.Id}\")"); + return SignInResult.NotAllowed; + } + return await base.PreSignInCheck(user); } } diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUser.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUser.cs index c7aceb7bf9..1e6eea7c35 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUser.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUser.cs @@ -112,6 +112,11 @@ public class IdentityUser : FullAuditedAggregateRoot, IUser, IHasEntityVer /// public virtual int AccessFailedCount { get; protected internal set; } + /// + /// Should change password on next login. + /// + public virtual bool ShouldChangePasswordOnNextLogin { get; protected internal set; } + /// /// A version value that is increased whenever the entity is changed. /// @@ -368,6 +373,11 @@ public class IdentityUser : FullAuditedAggregateRoot, IUser, IHasEntityVer IsActive = isActive; } + public virtual void SetShouldChangePasswordOnNextLogin(bool shouldChangePasswordOnNextLogin) + { + ShouldChangePasswordOnNextLogin = shouldChangePasswordOnNextLogin; + } + public override string ToString() { return $"{base.ToString()}, UserName = {UserName}";