public void Login_BadRequest_UserNotExists()
        {
            const string userName = "******";

            _userRepository.GetForLogIn(userName).Returns((null, null));

            var response = _userController.LogIn(new UserLogInInfo {
                Email    = "userName",
                Password = "******"
            });

            Assert.That(response, Is.TypeOf <BadRequestObjectResult>());
        }
Exemple #2
0
        public IActionResult LogIn([FromBody] UserLogInInfo userLogin)
        {
            var(user, passwordHash) = _userRepository.GetForLogIn(userLogin.Email);

            if (user == null)
            {
                return(BadRequest("User not found"));
            }

            if (!_bubelSoftUserPassword.Verify(userLogin, passwordHash))
            {
                return(BadRequest("Password is invalid"));
            }

            return(Ok(_bubelSoftJwtToken.CreateFor(user)));
        }