aboutsummaryrefslogtreecommitdiff
path: root/Backend/Api
diff options
context:
space:
mode:
Diffstat (limited to 'Backend/Api')
-rw-r--r--Backend/Api/Api/Controllers/AuthController.cs10
-rw-r--r--Backend/Api/Api/Controllers/PostController.cs2
-rw-r--r--Backend/Api/Api/Services/PostService.cs2
3 files changed, 12 insertions, 2 deletions
diff --git a/Backend/Api/Api/Controllers/AuthController.cs b/Backend/Api/Api/Controllers/AuthController.cs
index abb7adc..b63665b 100644
--- a/Backend/Api/Api/Controllers/AuthController.cs
+++ b/Backend/Api/Api/Controllers/AuthController.cs
@@ -120,5 +120,15 @@ namespace Api.Controllers
return base.Content(html, "text/html");
}
}
+ [HttpGet("jwttoid")]
+ [Authorize(Roles = "User")]
+ public async Task<ActionResult<string>> JwtToUserId()
+ {
+ var userid = await _userService.UserIdFromJwt();
+ if (userid != null)
+ return Ok(userid);
+ return BadRequest();
+ }
+
}
}
diff --git a/Backend/Api/Api/Controllers/PostController.cs b/Backend/Api/Api/Controllers/PostController.cs
index 61a4f48..33c240c 100644
--- a/Backend/Api/Api/Controllers/PostController.cs
+++ b/Backend/Api/Api/Controllers/PostController.cs
@@ -56,7 +56,7 @@ namespace Api.Controllers
}
return BadRequest();
}
- [HttpGet("posts/delete/{id}")]
+ [HttpDelete("posts/delete/{id}")]
[Authorize(Roles = "User")]
public async Task<ActionResult<string>> deletePost(string id)
{
diff --git a/Backend/Api/Api/Services/PostService.cs b/Backend/Api/Api/Services/PostService.cs
index 16ebbb7..07e225e 100644
--- a/Backend/Api/Api/Services/PostService.cs
+++ b/Backend/Api/Api/Services/PostService.cs
@@ -115,7 +115,7 @@ namespace Api.Services
foreach (var image in p.images)
System.IO.File.Delete(image.path);
- await _posts.DeleteOneAsync(postid);
+ await _posts.FindOneAndDeleteAsync(x => x._id==postid);
return true;
}