public IActionResult Authenticate([FromBody] UserDto userDto) { User user = _userService.Authenticate(userDto.Email, userDto.Password); if (user == null) { return(BadRequest(new { message = "Username or password is incorrect!" })); } string token = _jwtProvider.GetJWT(user.Id, Role.User); return(Ok(new { user.Id, user.Email, user.Name, user.Surname, token })); }
public IActionResult Authenticate([FromBody] BusinessDto businesDto) { Business business = _businessService.Authenticate(businesDto.Email, businesDto.Password); if (business == null) { return(BadRequest(new { message = "Username or password is incorrect!" })); } string token = _jwtProvider.GetJWT(business.Id, Role.Business); return(Ok(new { business.Id, business.CompanyName, business.Email, business.Address, token })); }