diff options
| author | Danail Dimitrov <danaildimitrov321@gmail.com> | 2020-12-18 13:17:46 +0200 |
|---|---|---|
| committer | Danail Dimitrov <danaildimitrov321@gmail.com> | 2020-12-18 13:17:46 +0200 |
| commit | 844ee0cba02d245ba5c8ba77282235066549ce8d (patch) | |
| tree | fe91e87d76a8a20049e57645709619a323d40098 /src/DevHive.Web/Controllers | |
| parent | 13cdc46cbe5ebe1aa607f90e554de5f222adce8d (diff) | |
| parent | f22f708a3b98dbee905786e076bb0d171316bae8 (diff) | |
| download | DevHive-844ee0cba02d245ba5c8ba77282235066549ce8d.tar DevHive-844ee0cba02d245ba5c8ba77282235066549ce8d.tar.gz DevHive-844ee0cba02d245ba5c8ba77282235066549ce8d.zip | |
Merge branch 'dev' of github.com:Team-Kaleidoscope/DevHive into dev
Diffstat (limited to 'src/DevHive.Web/Controllers')
| -rw-r--r-- | src/DevHive.Web/Controllers/UserController.cs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/DevHive.Web/Controllers/UserController.cs b/src/DevHive.Web/Controllers/UserController.cs index e339f70..35c39df 100644 --- a/src/DevHive.Web/Controllers/UserController.cs +++ b/src/DevHive.Web/Controllers/UserController.cs @@ -9,7 +9,6 @@ using DevHive.Web.Models.Identity.User; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using DevHive.Common.Models.Identity; -using DevHive.Common.Models; namespace DevHive.Web.Controllers { @@ -56,8 +55,11 @@ namespace DevHive.Web.Controllers //Read [HttpGet] - public async Task<IActionResult> GetById(Guid id) + public async Task<IActionResult> GetById(Guid id, [FromHeader] string authorization) { + if (!await this._userService.ValidJWT(id, authorization)) + return new UnauthorizedResult(); + UserServiceModel userServiceModel = await this._userService.GetUserById(id); UserWebModel userWebModel = this._userMapper.Map<UserWebModel>(userServiceModel); @@ -66,8 +68,11 @@ namespace DevHive.Web.Controllers //Update [HttpPut] - public async Task<IActionResult> Update(Guid id, [FromBody] UpdateUserWebModel updateModel) + public async Task<IActionResult> Update(Guid id, [FromBody] UpdateUserWebModel updateModel, [FromHeader] string authorization) { + if (!await this._userService.ValidJWT(id, authorization)) + return new UnauthorizedResult(); + UpdateUserServiceModel updateUserServiceModel = this._userMapper.Map<UpdateUserServiceModel>(updateModel); updateUserServiceModel.Id = id; @@ -80,8 +85,11 @@ namespace DevHive.Web.Controllers //Delete [HttpDelete] - public async Task<IActionResult> Delete(Guid id) + public async Task<IActionResult> Delete(Guid id, [FromHeader] string authorization) { + if (!await this._userService.ValidJWT(id, authorization)) + return new UnauthorizedResult(); + await this._userService.DeleteUser(id); return new OkResult(); } |
