Disable User in ASPNET identity 2.0

后端 未结 10 1139
谎友^
谎友^ 2020-11-30 23:50

I am looking for a way to disable the user instead of deleting them from the system, this is to keep the data integrity of the related data. But seems ASPNET identity only

10条回答
  •  無奈伤痛
    2020-12-01 00:06

    This all I did actually:

        var lockoutEndDate = new DateTime(2999,01,01);
        UserManager.SetLockoutEnabled(userId,true);
        UserManager.SetLockoutEndDate(userId, lockoutEndDate);
    

    Which is basically to enable lock out (if you don't do this by default already, and then set the Lockout End Date to some distant value.

提交回复
热议问题