public IActionResult Put(Comment comment) { var user = _authHandler.UserFromClaimsPrincipal(User); if (string.IsNullOrWhiteSpace(comment.Uuid) || string.IsNullOrWhiteSpace(comment.Content)) { _logger.LogInformation("Comment uuid or content is empty."); _logger.LogInformation($"Terminating session. User: {user.Uuid}" + $", IP: {HttpContext?.Connection?.RemoteIpAddress?.ToString() ?? "Unknown IP"}"); _authHandler.TerminateSession(user); return(BadRequest()); } if (!SecureGuid.VerifyGuid(comment.Uuid, out _)) { _logger.LogInformation("Comment UUID is invalid."); _logger.LogInformation($"Terminating session. User: {user.Uuid}" + $", IP: {HttpContext?.Connection?.RemoteIpAddress?.ToString() ?? "Unknown IP"}"); _authHandler.TerminateSession(user); return(BadRequest()); } if (!_database.VerifyCommentUser(user, comment)) { _logger.LogInformation("Requester is not comment creator."); _logger.LogInformation($"Terminating session. User: {user.Uuid}" + $", IP: {HttpContext?.Connection?.RemoteIpAddress?.ToString() ?? "Unknown IP"}"); _authHandler.TerminateSession(user); return(BadRequest()); } if (_database.UpdateComment(comment, user)) { _activityLogger.LogEditComment(Request.HttpContext.Connection.RemoteIpAddress, user, comment); return(Ok()); } _logger.LogInformation("Database failed to update comment."); _logger.LogInformation($"Terminating session. User: {user.Uuid}" + $", IP: {HttpContext?.Connection?.RemoteIpAddress?.ToString() ?? "Unknown IP"}"); _authHandler.TerminateSession(user); return(BadRequest()); }