Пример #1
0
        public ManaDbUserLockout(ManaUserLockout model)
        {
            if (model == null)
            {
                throw new ArgumentException(nameof(model));
            }

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