File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,12 +7,6 @@ const validators = [];
77let popped_modals_ct = 0 ;
88
99window . QPixel = {
10- csrfToken : ( ) => {
11- const token = $ ( 'meta[name="csrf-token"]' ) . attr ( 'content' ) ;
12- QPixel . csrfToken = ( ) => token ;
13- return token ;
14- } ,
15-
1610 createNotification : function ( type , message ) {
1711 // Some messages include a date stamp, `append_date` governs that.
1812 let append_date = false ;
@@ -320,7 +314,6 @@ window.QPixel = {
320314
321315 fetch : async ( uri , init ) => {
322316 const defaultHeaders = {
323- 'X-CSRF-Token' : QPixel . csrfToken ( ) ,
324317 // X-Requested-With is necessary for request.xhr? to work
325318 'X-Requested-With' : 'XMLHttpRequest' ,
326319 'Content-Type' : 'application/json' ,
Original file line number Diff line number Diff line change 44class ApplicationController < ActionController ::Base
55 # Prevent CSRF attacks by raising an exception.
66 # For APIs, you may want to use :null_session instead.
7- protect_from_forgery with : :exception
7+ protect_from_forgery with : :exception , store : :cookie
88 before_action :configure_permitted_parameters , if : :devise_controller?
99 before_action :set_globals
1010 before_action :enforce_signed_in , unless : :devise_controller?
@@ -417,4 +417,10 @@ def require_sudo
417417 redirect_to user_sudo_path
418418 end
419419 end
420+
421+ # default request_authenticity_tokens only checks form tokens and request.x_csrf_token
422+ # for some reason, even if cookie-based strategy is officially supported, it's not checked here
423+ def request_authenticity_tokens
424+ super << csrf_token_storage_strategy . fetch ( request )
425+ end
420426end
Original file line number Diff line number Diff line change 7171 < script id ="MathJax-script " async src ="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js "> </ script >
7272<% end %>
7373
74- <%= csrf_meta_tags %>
75-
7674<%= yield ( :head ) %>
7775
7876<% if content_for? :twitter_card_meta %>
Original file line number Diff line number Diff line change @@ -411,12 +411,6 @@ interface QPixel {
411411 */
412412 addPrePostValidation ?: ( callback : PostValidator ) => void ;
413413
414- /**
415- * Get the current CSRF anti-forgery token. Should be passed as the X-CSRF-Token header when
416- * making AJAX POST requests.
417- */
418- csrfToken ?: ( ) => string ;
419-
420414 /**
421415 * Create a notification popup - not an inbox notification.
422416 * @param type the type to apply to the popup - warning, danger, etc.
You can’t perform that action at this time.
0 commit comments