Skip to content

Conversation

@jeevansridharan
Copy link

@jeevansridharan jeevansridharan commented Nov 19, 2025

Summary by Sourcery

Ensure CSRF token is correctly retrieved when toggling featured status in the organizer interface

Bug Fixes:

  • Replace hardcoded pretalx CSRF cookie lookup with a generalized retrieval function for featured toggle requests

Enhancements:

  • Introduce getCsrfToken helper to search eventyay_csrftoken, pretalx_csrftoken, and csrftoken cookies

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 19, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Enhances CSRF token retrieval in the featured toggle AJAX call by introducing a dedicated lookup function that checks multiple cookie names and updates the request header to use this new selector.

Class diagram for updated CSRF token retrieval logic

classDiagram
    class main_js {
        +handleFeaturedChange(element)
        +initScrollPosition()
        +getCsrfToken()
        +getCookie(name)
    }
    main_js : getCsrfToken() checks ["eventyay_csrftoken", "pretalx_csrftoken", "csrftoken"]
    main_js : getCookie(name) returns cookie value
    main_js : handleFeaturedChange(element) uses getCsrfToken()
Loading

Flow diagram for CSRF token selection in AJAX request

flowchart TD
    A["handleFeaturedChange() called"] --> B["getCsrfToken() called"]
    B --> C{"Any CSRF cookie found?"}
    C -- Yes --> D["Return cookie value"]
    C -- No --> E["Return empty string"]
    D & E --> F["Set X-CSRFToken header in AJAX request"]
Loading

File-Level Changes

Change Details Files
Replace direct CSRF cookie lookup with a unified helper
  • Updated the POST header to use getCsrfToken() instead of hard-coded getCookie("pretalx_csrftoken")
app/eventyay/static/orga/js/main.js
Added a resilient getCsrfToken helper
  • Defined an array of potential CSRF cookie names
  • Looped through names to return the first existing token
  • Fallback to empty string if no token is found
app/eventyay/static/orga/js/main.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Member

@mariobehling mariobehling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for closing and opening this? There is no issue about this. Usually PRs require an issue in most cases that outlines the problem. Please do so and update the PR description with "Fixes #issue number".

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes CSRF token retrieval for the featured toggle functionality by introducing a more flexible cookie lookup mechanism that supports multiple cookie name conventions.

  • Introduced a getCsrfToken() helper function that searches for CSRF tokens across multiple cookie names (eventyay_csrftoken, pretalx_csrftoken, csrftoken)
  • Updated the featured toggle AJAX request to use the new helper instead of hardcoded cookie lookup

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants