public async Task <IActionResult> UpdateDetailsForUser(string uuid, [FromBody] UserDetails details, CancellationToken ct = default) { if (!AuthenticationUtilities.IsSameUserOrPrivileged(User, uuid)) { return(Unauthorized("You do not have access to this endpoint")); } return(Ok(await _userRepository.UpdateUserDetailsAsync(uuid, details, ct))); }
public async Task <IActionResult> DeletePost(int feedPostId, CancellationToken ct = default) { if (!AuthenticationUtilities.IsAllowedFeed(User)) { return(BadRequest("User has been banned from Feed")); } FeedPost post = await _feedService.GetByIdAsync(feedPostId); if (!AuthenticationUtilities.IsSameUserOrPrivileged(User, post.PosterUUID)) { return(Unauthorized("You do not have access to modify this post")); } await _feedService.MarkPostAsDeletedAsync(feedPostId, ct); return(Ok()); }
public async Task <IActionResult> DeleteAditLog(int aditLogId, CancellationToken ct = default) { if (!AuthenticationUtilities.IsAllowedFeed(User)) { return(BadRequest("User has been banned from Feed")); } AditLog aditLog = await _feedService.GetAditLogAsync(aditLogId); if (!AuthenticationUtilities.IsSameUserOrPrivileged(User, aditLog.PosterUUID)) { return(Unauthorized("You do not have access to modify this Adit Log")); } await _feedService.MarkAditLogAsDeletedAsync(aditLogId, ct); return(Ok()); }
public async Task <IActionResult> DeleteComment(int commentId, CancellationToken ct = default) { if (!AuthenticationUtilities.IsAllowedFeed(User)) { return(BadRequest("User has been banned from Feed")); } FeedComment comment = await _feedService.GetCommentByIdAsync(commentId, ct); if (!AuthenticationUtilities.IsSameUserOrPrivileged(User, comment.UserUUID)) { return(Unauthorized("You do not have access to delete this comment")); } await _feedService.MarkFeedCommentAsDeletedAsync(commentId, ct); return(Ok()); }