Changeset 057037b for backend/Controllers
- Timestamp:
- 04/11/22 15:29:19 (3 years ago)
- Branches:
- master
- Children:
- 7a983b0
- Parents:
- b66b3ac
- Location:
- backend/Controllers
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
backend/Controllers/UsersController.cs
rb66b3ac r057037b 1 1 namespace backend.Controllers; 2 2 3 using backend.DTOs; 3 4 using backend.Helpers; 4 5 using backend.Models; … … 10 11 public class UsersController : ControllerBase 11 12 { 12 private IUserService _userService;13 private readonly IUserService _userService = null; 13 14 14 15 public UsersController(IUserService userService) … … 17 18 } 18 19 19 [HttpPost(" authenticate")]20 public IActionResultAuthenticate(AuthenticateRequest model)20 [HttpPost("login")] 21 public async Task<AuthenticateResponse> Authenticate(AuthenticateRequest model) 21 22 { 22 var response = _userService.Authenticate(model);23 var response = await _userService.Authenticate(model); 23 24 24 25 if (response == null) 25 return BadRequest(new { message = "Username or password is incorrect" });26 throw new Exception("Email or password is incorrect"); 26 27 27 return Ok(response);28 return response; 28 29 } 29 30 30 [Authorize] 31 [HttpGet] 32 public IActionResult GetUserById(int id) 31 [HttpPost("register")] 32 public async Task<AuthenticateResponse> Register(CreateUserRequest req) 33 33 { 34 var users = _userService.GetById(id);35 return Ok(users);34 var response = await _userService.Register(req); 35 return response; 36 36 } 37 37 }
Note:
See TracChangeset
for help on using the changeset viewer.