]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
fix(ERP-244): fix CSRF validation error in ShiftReminderController origin/feature_filippov_ERP-244_fix_shift_reminder_csrf
authorAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Fri, 27 Feb 2026 15:06:41 +0000 (18:06 +0300)
committerAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Fri, 27 Feb 2026 15:06:41 +0000 (18:06 +0300)
- Disable CSRF validation on ShiftReminderController: endpoint is
  protected by session authentication (AccessControl, roles=['@']).
  CSRF cookies may be absent in browsers with strict privacy settings,
  causing false 400 errors for legitimate authenticated users.
- Stop retrying on 400/401/403 responses in shift-reminder.js to prevent
  cascading error floods in logs when auth/validation fails.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
erp24/controllers/ShiftReminderController.php
erp24/web/js/shift-reminder.js

index 6378dd4e86f70e64a130f28393c2f62a2d415f5b..6f66c2c9e0f0cd0711fee9e2799294149db94f92 100644 (file)
@@ -21,6 +21,13 @@ use yii_app\services\ShiftReminderService;
  */
 class ShiftReminderController extends Controller
 {
+    /**
+     * Disable CSRF validation — endpoint is protected by session authentication
+     * (AccessControl requires authenticated user). CSRF cookies may be absent
+     * in browsers with strict privacy settings, causing false 400 errors.
+     */
+    public $enableCsrfValidation = false;
+
     /**
      * {@inheritdoc}
      */
index 5267b9a9d792a0a93a024064f556c0c8a5b18569..83cdfca57bafbd8bebd37a2d1a2e4c0ae6e05e35 100644 (file)
             return;
         }
 
+        if (xhr.status === 400 || xhr.status === 401 || xhr.status === 403) {
+            // Auth/validation error - no point retrying, stop polling
+            console.error('ShiftReminder: server rejected request (' + xhr.status + '), polling stopped.');
+            return;
+        }
+
         // Network error - implement exponential backoff
         if (state.retryCount < CONFIG.retryIntervals.length - 1) {
             state.retryCount++;