public RegiDbUserLockout(RegiUserLockout model) { if (model == null) { throw new ArgumentException(nameof(model)); } UserId = model.UserId; Attempts = model.Attempts; LockEnd = model.LockEnd; }
public async Task SetLockoutEndDateAsync(RegiAuthUser user, DateTimeOffset lockoutEnd) { var info = new RegiUserLockout { LockEnd = lockoutEnd.DateTime.ToLocalTime(), UserId = user.Id }; try { await _lockoutStore.UpdateUserTime(info); } catch (RecordNotFoundException) { await _lockoutStore.InsertUserTime(info); } }
public async Task InsertUserAttempts(RegiUserLockout userInfo) { try { using (var connection = await GetConnectionAsync()) { await connection.ExecuteAsync(RegistrarQueries.LockoutInsertAttempts, userInfo); } } catch (Exception e) { if (e is RecordNotFoundException) { throw; } throw new Exception("Could not Insert User Lockout Attempts"); } }
public async Task <int> IncrementAccessFailedCountAsync(RegiAuthUser user) { RegiUserLockout info; try { info = await _lockoutStore.GetUserInfo(user.Id); info.Attempts++; await _lockoutStore.UpdateUserAttempts(info); } catch (RecordNotFoundException) { info = new RegiUserLockout { UserId = user.Id, Attempts = 1 }; await _lockoutStore.InsertUserAttempts(info); } return(info.Attempts); }
public async Task UpdateUserTime(RegiUserLockout userInfo) { try { using (var connection = await GetConnectionAsync()) { var rows = await connection.ExecuteAsync(RegistrarQueries.LockoutUpdateTime, userInfo); if (rows == 0) { throw new RecordNotFoundException(); } } } catch (Exception e) { if (e is RecordNotFoundException) { throw; } throw new Exception("Could not Update User Lockout Info"); } }