Skip to content

Commit daa60d8

Browse files
committed
Implement SetLockoutEnabled
1 parent 0b81c6b commit daa60d8

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/AspNet.Identity.MongoDB/UserStore.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ public Task<bool> GetLockoutEnabledAsync(TUser user)
256256

257257
public Task SetLockoutEnabledAsync(TUser user, bool enabled)
258258
{
259-
throw new NotImplementedException();
259+
user.LockoutEnabled = enabled;
260+
return Task.FromResult(0);
260261
}
261262
}
262263
}

src/IntegrationTests/UserLockoutStoreTests.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void AccessFailed_IncrementsAccessFailedCount()
2525
public void IncrementAccessFailedCount_ReturnsNewCount()
2626
{
2727
var store = new UserStore<IdentityUser>(null);
28-
var user = new IdentityUser { UserName = "bob" };
28+
var user = new IdentityUser {UserName = "bob"};
2929

3030
var count = store.IncrementAccessFailedCountAsync(user);
3131

@@ -73,5 +73,19 @@ public void AccessFailed_ExceedsMaxFailedAccessAttempts_LocksAccount()
7373
var lockoutEndDate = manager.GetLockoutEndDate(user.Id);
7474
Expect(lockoutEndDate.Subtract(DateTime.UtcNow).TotalHours, Is.GreaterThan(0.9).And.LessThan(1.1));
7575
}
76+
77+
[Test]
78+
public void SetLockoutEnabled()
79+
{
80+
var manager = GetUserManager();
81+
var user = new IdentityUser {UserName = "bob"};
82+
manager.Create(user);
83+
84+
manager.SetLockoutEnabled(user.Id, true);
85+
Expect(manager.GetLockoutEnabled(user.Id));
86+
87+
manager.SetLockoutEnabled(user.Id, false);
88+
Expect(manager.GetLockoutEnabled(user.Id), Is.False);
89+
}
7690
}
7791
}

0 commit comments

Comments
 (0)