public ActionResult Validate(string token, string username) { bool exists = new Data.UserRepository().GetUser(username) != null; if (!exists) { return(NotFound("The user was not found.")); } string tokenUsername = TokenManager.ValidateToken(token, _config); if (username.Equals(tokenUsername)) { return(Ok()); } return(BadRequest()); }
public ActionResult Login([FromBody] User user) { User u = new Data.UserRepository().GetUser(user.Username); if (u == null) { return(NotFound("The user was not found.")); } bool credentials = u.Password.Equals(user.Password); if (!credentials) { return(Unauthorized("The username/password combination was wrong.")); } var access_token = TokenManager.GenerateToken(user.Username, _config); return(Ok(new { id = u.Username, name = u.Username, access_token })); }
public void SetUp() { _repository = new Data.UserRepository(ConnectionString); }
public User() { _userRepository = Data.UserRepository.Instance; _accountService = new AccountService(); }