diff options
author | branislav.radivojevic <wafflemynxyt@gmail.com> | 2022-11-14 11:29:17 +0100 |
---|---|---|
committer | branislav.radivojevic <wafflemynxyt@gmail.com> | 2022-11-14 11:29:17 +0100 |
commit | c0c7b37d7abaa7d9519c58d5c0caefd0ba42b4de (patch) | |
tree | 776f0d79a10a581b3955e73392eeb9bbea71fb18 /Backend | |
parent | a30222749d891314d4aad1ac8798ae115392407c (diff) |
user name, pfp bug
Diffstat (limited to 'Backend')
-rw-r--r-- | Backend/Api/Api/Controllers/UserController.cs | 6 | ||||
-rw-r--r-- | Backend/Api/Api/Services/UserService.cs | 4 |
2 files changed, 4 insertions, 6 deletions
diff --git a/Backend/Api/Api/Controllers/UserController.cs b/Backend/Api/Api/Controllers/UserController.cs index 4e0f0a3..965ad6b 100644 --- a/Backend/Api/Api/Controllers/UserController.cs +++ b/Backend/Api/Api/Controllers/UserController.cs @@ -17,13 +17,9 @@ namespace Api.Controllers } [HttpPost("profile/pfp")] [Authorize(Roles = "User")] - public async Task<ActionResult<User>> setPfp([FromBody] IFormFile image) + public async Task<ActionResult<User>> setPfp(IFormFile image) { - if (image == null) - return BadRequest(); var id = await _userService.UserIdFromJwt(); - if (id == null) - return Unauthorized(); if(await _userService.AddOrChangePfp(id,image)) return Ok(); return BadRequest(); diff --git a/Backend/Api/Api/Services/UserService.cs b/Backend/Api/Api/Services/UserService.cs index d8361cd..8e7cd42 100644 --- a/Backend/Api/Api/Services/UserService.cs +++ b/Backend/Api/Api/Services/UserService.cs @@ -324,7 +324,7 @@ namespace Api.Services Directory.CreateDirectory(folderPath); var filename = image.FileName; var ext = Path.GetExtension(filename).ToLowerInvariant(); - var name ="PFP - " + user._id; + var name =user._id; var fullPath = Path.Combine(folderPath, name+ext); if (System.IO.File.Exists(fullPath)) System.IO.File.Delete(fullPath); @@ -347,6 +347,7 @@ namespace Api.Services if(user == null) return null; var tosend = new UserSend(); + tosend.name = user.name; tosend.pfp = user.pfp; tosend.username = user.username; tosend._id= user._id; @@ -360,6 +361,7 @@ namespace Api.Services if (user == null) return null; var tosend = new UserSend(); + tosend.name = user.name; tosend.pfp = user.pfp; tosend.username = user.username; tosend._id = user._id; |