public IActionResult Login([FromBody] LoginForm model) { try { LoginUser user = _log.Login(model.UserNameInput); if (user == null) { return(Unauthorized()); } // check if password is correct if (!_authHelper.VerifyPasswordHash(model.PasswordInput, user.PasswordHash, user.PasswordSalt)) { return(Unauthorized()); } // Authentication successful return(Ok(new { user = user.UserInfo, token = _authHelper.GenerateToken(user) })); } catch (Exception e) { return(BadRequest(e.Message)); } }