How to disable a User in Identity 2.0?

后端 未结 3 1080
无人共我
无人共我 2020-12-30 13:15

I\'m trying to find a way to disable a user in Identity 2.0 and can\'t seem to find any info on it.

I would like to basically set a user to IsActive=false and would

3条回答
  •  天涯浪人
    2020-12-30 14:04

    Was doing some research on this and turns out the IdentityUser base class has some properties related to this topic. Namely: LockoutEnabled and LockoutEndDateUtc.

    It's sufficient to set LockoutEnabled to true and LockoutEndDateUtc to some future date in order for the standard SignInManager.PasswordSignInAsync to pick it up and act accordingly without any overrides or customizations.

    And if you want to just disable the user without specifying any exact date of reactivation you can just set it to DateTime.MaxValue.

提交回复
热议问题