public RegiDbUserLockout(RegiUserLockout model)
        {
            if (model == null)
            {
                throw new ArgumentException(nameof(model));
            }

            UserId   = model.UserId;
            Attempts = model.Attempts;
            LockEnd  = model.LockEnd;
        }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
 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");
     }
 }
Exemple #4
0
        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);
        }
Exemple #5
0
        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");
            }
        }