public ManaDbUserLockout(ManaUserLockout model) { if (model == null) { throw new ArgumentException(nameof(model)); } UserId = UserId; Attempts = model.Attempts; LockEnd = model.LockEnd; }
public async Task SetLockoutEndDateAsync(ManaAuthUser user, DateTimeOffset lockoutEnd) { var info = new ManaUserLockout { LockEnd = lockoutEnd.DateTime.ToLocalTime(), UserId = user.Id }; try { await _lockoutStore.UpdateUserTime(info); } catch (RecordNotFoundException) { await _lockoutStore.InsertUserTime(info); } }
public async Task InsertUserTime(ManaUserLockout userInfo) { try { using (var connection = await GetConnectionAsync()) { await connection.ExecuteAsync(ManagementQueries.LockoutInsertTime, userInfo); } } catch (Exception e) { if (e is RecordNotFoundException) { throw; } throw new Exception("Could not insert User Lockout Time"); } }
public async Task UpdateUserAttempts(ManaUserLockout userInfo) { try { using (var connection = await GetConnectionAsync()) { var rows = await connection.ExecuteAsync(ManagementQueries.LockoutUpdateAttempts, userInfo); if (rows == 0) { throw new RecordNotFoundException(); } } } catch (Exception e) { if (e is RecordNotFoundException) { throw; } throw new Exception("Could not Update User Lockout Token Attempts"); } }
public async Task <int> IncrementAccessFailedCountAsync(ManaAuthUser user) { ManaUserLockout info; try { info = await _lockoutStore.GetUserInfo(user.Id); info.Attempts++; await _lockoutStore.UpdateUserAttempts(info); } catch (RecordNotFoundException) { info = new ManaUserLockout { UserId = user.Id, Attempts = 1 }; await _lockoutStore.InsertUserAttempts(info); } return(info.Attempts); }