Browse Source

Add `ShouldChangePasswordOnNextLogin` to `IdenttiyUser`.

pull/15708/head
maliming 3 years ago
parent
commit
ff966b2965
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 6
      modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpSignInManager.cs
  2. 10
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUser.cs

6
modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpSignInManager.cs

@ -85,6 +85,12 @@ public class AbpSignInManager : SignInManager<IdentityUser>
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);
}
}

10
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUser.cs

@ -112,6 +112,11 @@ public class IdentityUser : FullAuditedAggregateRoot<Guid>, IUser, IHasEntityVer
/// </summary>
public virtual int AccessFailedCount { get; protected internal set; }
/// <summary>
/// Should change password on next login.
/// </summary>
public virtual bool ShouldChangePasswordOnNextLogin { get; protected internal set; }
/// <summary>
/// A version value that is increased whenever the entity is changed.
/// </summary>
@ -368,6 +373,11 @@ public class IdentityUser : FullAuditedAggregateRoot<Guid>, IUser, IHasEntityVer
IsActive = isActive;
}
public virtual void SetShouldChangePasswordOnNextLogin(bool shouldChangePasswordOnNextLogin)
{
ShouldChangePasswordOnNextLogin = shouldChangePasswordOnNextLogin;
}
public override string ToString()
{
return $"{base.ToString()}, UserName = {UserName}";

Loading…
Cancel
Save