Ejemplo n.º 1
0
        public void AddUserAuth_adds_auth_data_and_find_by_id_finds_it()
        {
            _userAuthenticationDataRepository.AddUserAuth(authData);

            var found = _userAuthenticationDataRepository.FindUserAuthById(authData.UserId);

            found.Should().NotBeNull();
            found.Should().BeEquivalentTo(authData);
        }
Ejemplo n.º 2
0
        protected override Task <RequestStatus> HandleCommand(ChangePasswordCommand request, CancellationToken cancellationToken)
        {
            var userAuthData = _authenticationDataRepository.FindUserAuthById(request.SignedInUser.UserId);

            if (userAuthData == null)
            {
                throw new UserNotFoundException($"Cannot find {request.SignedInUser.UserId} user");
            }

            userAuthData.Password = request.NewPassword;

            _authenticationDataRepository.UpdateUserAuth(userAuthData);

            _logger.LogDebug("User {user} has changed password", request.SignedInUser.UserId);
            var response = RequestStatus.CreateFromCommandContext(request.CommandContext, Status.COMPLETED);

            return(Task.FromResult(response));
        }