public async Task <LoginAttemptDto> Handle(RejectLoginAttemptCommand request, CancellationToken cancellationToken)
        {
            var loginAttempt = await _loginAttemptRepository.GetByIdAsync(request.LoginAttemptId, cancellationToken);

            if (loginAttempt == null || loginAttempt.Secret != request.Secret)
            {
                return(null);
            }

            _loginAttemptRepository.Delete(loginAttempt);
            await _unitOfWork.CommitAsync(cancellationToken);

            return(LoginAttemptDto.FromLoginAttempt(loginAttempt));
        }
예제 #2
0
        public async Task <LoginAttemptStatus> Handle(DoLoginCommand request, CancellationToken cancellationToken)
        {
            var loginAttempt = await _loginAttemptRepository.GetByIdAsync(request.LoginAttemptId, cancellationToken);

            if (loginAttempt == null)
            {
                return(LoginAttemptStatus.Deleted);
            }

            var loginAttemptDto = LoginAttemptDto.FromLoginAttempt(loginAttempt);

            await LoginIfApproved(loginAttemptDto, request.RememberLogin, request.ClientId);

            await DeleteLoginAttemptIfExpiredOrApproved(loginAttemptDto, loginAttempt, cancellationToken);

            return(loginAttemptDto.Status);
        }
        public async Task <LoginAttemptDto> Handle(GetLoginAttemptQuery request, CancellationToken cancellationToken)
        {
            var loginAttempt = await _loginAttemptRepository.GetByIdAsync(request.LoginAttemptId, cancellationToken);

            return(loginAttempt == null ? null : LoginAttemptDto.FromLoginAttempt(loginAttempt));
        }