User Lockout in .net 4.5.1 ASP.NET MVC 5

前端 未结 1 1707
灰色年华
灰色年华 2021-01-31 21:07

So in the new .Net Framework 4.5.1 AspNetUser table does not have a column to lock user out after a finite number of unsuccessful attempts. Are there frameworks or solutions bui

相关标签:
1条回答
  • 2021-01-31 21:48

    In the upcoming 2.0 Identity release, there is support for Account Lockout

    Configuration:

        manager.UserLockoutEnabledByDefault = true; // Enables ability to lockout for users when created
        manager.DefaultAccountLockoutTimeSpan = TimeSpan.FromMinutes(5);
        manager.MaxFailedAccessAttemptsBeforeLockout = 5;
    

    Usage:

    manager.IsLockedOutAsync(user.Id) // Check for lockout
    manager.ResetAccessFailedCountAsync(user.Id); // Clear failed count after success
    manager.AccessFailedAsync(user.Id); // Record a failure (this will lockout if enabled)
    manager.SetLockoutEnabled(user.Id, enabled) // Enables or disables lockout for a user 
    
    0 讨论(0)
提交回复
热议问题