diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2020-12-12 13:53:53 +0200 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2020-12-12 13:53:53 +0200 |
| commit | fb9a24796e859e434c83ba2f5e84895143fc0232 (patch) | |
| tree | d234500ca73359f21cabd9d99699916a6485c475 /API/Controllers | |
| parent | 372cbb34fe20882549bb0bba569b5da96081d507 (diff) | |
| download | DevHive-fb9a24796e859e434c83ba2f5e84895143fc0232.tar DevHive-fb9a24796e859e434c83ba2f5e84895143fc0232.tar.gz DevHive-fb9a24796e859e434c83ba2f5e84895143fc0232.zip | |
Implemented register request, made login require correct password, removed create user request, brought back Roles.cs and moved roles constants to UserRoles, fixed authorization in UserController
Diffstat (limited to 'API/Controllers')
| -rw-r--r-- | API/Controllers/UserController.cs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/API/Controllers/UserController.cs b/API/Controllers/UserController.cs index 8618c1b..fd94283 100644 --- a/API/Controllers/UserController.cs +++ b/API/Controllers/UserController.cs @@ -10,7 +10,6 @@ using Microsoft.Extensions.Configuration; namespace API.Controllers { - [Authorize] [ApiController] [Route("/api/[controller]")] public class UserController: ControllerBase @@ -22,25 +21,22 @@ namespace API.Controllers this._service = new UserService(context, mapper, configuration.GetSection("AppSettings")); } - [AllowAnonymous] [HttpPost] [Route("login")] - public async Task<IActionResult> Login([FromBody] UserDTO userDTO) + public async Task<IActionResult> Login([FromBody] LoginDTO loginDTO) { - return await this._service.LoginUser(userDTO); + return await this._service.LoginUser(loginDTO); } - //Create - [AllowAnonymous] [HttpPost] - public async Task<IActionResult> Create([FromBody] UserDTO userDTO) + [Route("register")] + public async Task<IActionResult> Register([FromBody] RegisterDTO registerDto) { - return await this._service.CreateUser(userDTO); + return await this._service.RegisterUser(registerDto); } //Read [HttpGet] - [Authorize(Roles = UserRoles.Admin)] // Functionality, only for testing purposes public async Task<IActionResult> GetById(int id) { return await this._service.GetUserById(id); @@ -48,13 +44,15 @@ namespace API.Controllers //Update [HttpPut] + [Authorize] public async Task<IActionResult> Update(int id, [FromBody] UserDTO userDTO) { return await this._service.UpdateUser(id, userDTO); } //Delete - [HttpDelete] + [HttpDelete] + [Authorize] public async Task<IActionResult> Delete(int id) { return await this._service.DeleteUser(id); |
