Exemple #1
0
        public async Task <IActionResult> Login(UserLoginDto userLoginDto)
        {
            var user = await _userAuthentication.AuthenticateAsync(userLoginDto);

            var userLogged = new UserLoggedDto
            {
                Token         = GenerateJWT(user),
                Refresh_Token = user.RefreshToken,
                User          = Mapper.Map <UserDto>(user)
            };

            return(Ok(userLogged));
        }
Exemple #2
0
        public async Task MustLoginSuccessfullyAsync()
        {
            // Given
            var existingUser = UserBuilder.New()
                               .WithEmail(_userLoginDto.Email)
                               .WithPassword(_userLoginDto.Password)
                               .Build();

            // When
            _userMocks.MockUserGetByEmail(existingUser, _userLoginDto.Email);
            var userAuthenticated = await _userAuthentication.AuthenticateAsync(_userLoginDto);

            // Then
            Assert.Equal(existingUser.Email, userAuthenticated.Email);
        }