Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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));
        }