public IActionResult Get() { var users = userRepositories.GetAll(); if (users == null) { return(BadRequest()); } return(Ok(users)); }
public IActionResult Login([FromBody] LoginInputModel model) { var user = repository.GetAll().FirstOrDefault(u => u.Username == model.Username); // check if username exists if (user == null) { return(Unauthorized()); } // check if password is correct if (!VerifyPasswordHash(model.Password, user.PasswordHash, user.PasswordSalt)) { return(Unauthorized()); } // Authentication successful return(Ok(new { username = user.Username, user.IsAdmin, token = GenerateToken(user) })); }
public IEnumerable <UserToDoItem> GetAll() { return(repository.GetAll()); }