tududi/frontend/components
Chris 6c9902b584
fix: add CSRF token support to frontend requests (#1025)
This commit implements CSRF token support for all session-based API
requests to fix the "CSRF token missing" and "CSRF token mismatch" errors
introduced after CSRF protection was added in commit 62c4cc84.

Changes:
- Created csrfService.ts utility for fetching and caching CSRF tokens
- Added getPostHeadersWithCsrf() helper to authUtils for async token injection
- Updated all service files (*Service.ts) to include CSRF tokens in POST/PUT/PATCH/DELETE requests
- Updated components with inline fetch calls to use getCsrfToken()
- Fixed CSRF middleware to use single lusca instance instead of creating new instances per request
- Improved generateToken() to use req.csrfToken() when available
- Added CalDAV path exemption to CSRF protection

Technical details:
- CSRF tokens are fetched from /api/csrf-token endpoint
- Tokens are cached and reused across requests to avoid unnecessary fetches
- Tokens are included in x-csrf-token header for state-changing requests
- Public endpoints (login, register) remain exempt from CSRF protection
- Bearer token authentication remains exempt from CSRF protection

Files modified:
- Backend: app.js, middleware/csrf.js
- Frontend: 13 service files, 8 component files
- New file: frontend/utils/csrfService.ts

This ensures all session-based requests properly include CSRF tokens while
maintaining support for API token authentication.
2026-04-14 15:06:56 +03:00
..
Admin Fix bug 578 (#648) 2025-12-04 14:00:51 +02:00
Area Set verification modal on escape (#470) (#473) 2025-11-03 16:27:13 +02:00
Auth feat: Add OIDC/SSO authentication support (#1008) 2026-04-13 12:17:35 +03:00
Backup Update translations 2025-12-10 11:43:15 +02:00
Calendar Fix profile settings mobile layout (#694) 2025-12-10 09:10:23 +02:00
Habits Fix bug 733 (#735) 2025-12-27 21:00:52 +02:00
Inbox fix: add CSRF token support to frontend requests (#1025) 2026-04-14 15:06:56 +03:00
Metrics Fix today race condition (#75) 2025-06-13 14:20:24 +03:00
Note Introduce focus mode in notes (#891) 2026-03-03 00:29:03 +02:00
Notifications fix: add CSRF token support to frontend requests (#1025) 2026-04-14 15:06:56 +03:00
Productivity Fix redirect after task deletion to return to originating view (#887) 2026-03-01 16:07:02 +02:00
Profile fix: add CSRF token support to frontend requests (#1025) 2026-04-14 15:06:56 +03:00
Project fix: resolve inbox project creation bugs (#1018) 2026-04-13 20:32:57 +03:00
Shared Fix missing spacing between lists and headings in markdown (#775) 2026-01-14 17:42:26 +02:00
Sidebar fix: add CSRF token support to frontend requests (#1025) 2026-04-14 15:06:56 +03:00
Tag fix: add CSRF token support to frontend requests (#1025) 2026-04-14 15:06:56 +03:00
Task fix: use nullish coalescing for recurrence weekday to allow Sunday selection (#1014) 2026-04-13 19:07:20 +03:00
UniversalSearch fix: add CSRF token support to frontend requests (#1025) 2026-04-14 15:06:56 +03:00
About.tsx Feat main content revamp (#584) 2025-11-20 09:15:55 +02:00
Areas.tsx Feat main content revamp (#584) 2025-11-20 09:15:55 +02:00
Calendar.tsx Fix redirect after task deletion to return to originating view (#887) 2026-03-01 16:07:02 +02:00
Login.tsx feat: Add OIDC/SSO authentication support (#1008) 2026-04-13 12:17:35 +03:00
Navbar.tsx feat: Add MCP Integration with client-agnostic instructions (#953) 2026-03-20 16:55:49 +02:00
Notes.tsx Introduce focus mode in notes (#891) 2026-03-03 00:29:03 +02:00
Projects.tsx Fix projects order persist to localstorage (#868) 2026-02-27 00:35:44 +02:00
Register.tsx Refresh e2e tests (#606) 2025-11-29 21:25:42 +02:00
Sidebar.tsx feat: Add MCP Integration with client-agnostic instructions (#953) 2026-03-20 16:55:49 +02:00
Tags.tsx Feat improve task details (#585) 2025-11-21 18:43:10 +02:00
Tasks.tsx fix: add CSRF token support to frontend requests (#1025) 2026-04-14 15:06:56 +03:00
ViewDetail.tsx fix: add CSRF token support to frontend requests (#1025) 2026-04-14 15:06:56 +03:00
Views.tsx fix: add CSRF token support to frontend requests (#1025) 2026-04-14 15:06:56 +03:00