public IActionResult Authenticate([FromBody] AuthenticateionModel model) { var user = this._userRepo.Authenticate(model.Username, model.Password); if (user == null) { return(BadRequest(new { message = "Username or Password is incorrect" })); } return(Ok(user)); }
public IActionResult Register([FromBody] AuthenticateionModel model) { bool isUserNameUnique = this._userRepo.IsUniqueUser(model.Username); if (!isUserNameUnique) { return(BadRequest(new { message = "Username already exists" })); } var user = this._userRepo.Register(model.Username, model.Password); if (user == null) { return(BadRequest(new { message = "Error while registering" })); } return(Ok(user)); }