Skip to content

handle csrf token error#302

Open
Blue-B-code wants to merge 1 commit into
openimis:feature/vite-migrationfrom
Y-Note-SAS:feature-35788
Open

handle csrf token error#302
Blue-B-code wants to merge 1 commit into
openimis:feature/vite-migrationfrom
Y-Note-SAS:feature-35788

Conversation

@Blue-B-code
Copy link
Copy Markdown
Contributor

@Blue-B-code Blue-B-code commented Mar 4, 2026

Description

In production mode, the Django SESSION_COOKIE_AGE parameter is bound to CSRF_TOKEN via CSRF_USE_SESSIONS, which is set to true.

Therefore, when the session expires (after 8 hours), the CSRF token becomes invalid and generates a GraphQL error: errors[0].message = 'csrftoken'. We handle this error by intercepting the message and redirecting the user to the login page. We retain this functionality as it provides a useful security measure to ensure that the active user is indeed the one who knows the password.

Type of Change

  • Feature
  • Bug fix
  • Chore (Refactor, Docs, CI/CD)
  • Other, please specify

Related Issue(s) / Task(s)

  • Requires [link to github PR], [link to github PR] needs to be merged first before this one
  • Relates to [link to github PR], this needs to be merged before [link to github PR]
  • External reference (e.g., Jira):

Demo

Capture d’écran du 2026-03-04 13-45-34

Checklist

  • Unit tests added/modified
  • I18n / translation handled

@Blue-B-code Blue-B-code force-pushed the feature-35788 branch 2 times, most recently from d0d6645 to 1513125 Compare March 5, 2026 18:16
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Mar 5, 2026

@sonarqubecloud
Copy link
Copy Markdown

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants