public IActionResult Authenticate([FromBody] AuthenticateModel model)
        {
            var user = _userService.Authenticate(model.Username, model.Password);

            if (user == null)
            {
                return(BadRequest(new { message = "Username or password is incorrect" }));
            }

            return(Ok(user));
        }
示例#2
0
        public IActionResult Authenticate([FromBody] LoginModel login)
        {
            var user = _userService.Authenticate(login);

            return(user.Status switch
            {
                LoginStatus.Success => Ok(new
                {
                    success = true,
                    user
                }),
                _ => BadRequest(new
                {
                    success = false,
                    user
                }),
            });