Ignore:
Timestamp:
04/11/22 15:29:19 (3 years ago)
Author:
Danilo <danilo.najkov@…>
Branches:
master
Children:
7a983b0
Parents:
b66b3ac
Message:

backend full

Location:
backend/Controllers
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • backend/Controllers/UsersController.cs

    rb66b3ac r057037b  
    11namespace backend.Controllers;
    22
     3using backend.DTOs;
    34using backend.Helpers;
    45using backend.Models;
     
    1011public class UsersController : ControllerBase
    1112{
    12     private IUserService _userService;
     13    private readonly IUserService _userService = null;
    1314
    1415    public UsersController(IUserService userService)
     
    1718    }
    1819
    19     [HttpPost("authenticate")]
    20     public IActionResult Authenticate(AuthenticateRequest model)
     20    [HttpPost("login")]
     21    public async Task<AuthenticateResponse> Authenticate(AuthenticateRequest model)
    2122    {
    22         var response = _userService.Authenticate(model);
     23        var response = await _userService.Authenticate(model);
    2324
    2425        if (response == null)
    25             return BadRequest(new { message = "Username or password is incorrect" });
     26            throw new Exception("Email or password is incorrect");
    2627
    27         return Ok(response);
     28        return response;
    2829    }
    2930
    30     [Authorize]
    31     [HttpGet]
    32     public IActionResult GetUserById(int id)
     31    [HttpPost("register")]
     32    public async Task<AuthenticateResponse> Register(CreateUserRequest req)
    3333    {
    34         var users = _userService.GetById(id);
    35         return Ok(users);
     34        var response = await _userService.Register(req);
     35        return response;
    3636    }
    3737}
Note: See TracChangeset for help on using the changeset viewer.