File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 5454 // Button onClick disable selector with possible reenable after remote submission
5555 buttonDisableSelector : 'button[data-remote][data-disable-with], button[data-remote][data-disable]' ,
5656
57+ // Up-to-date Cross-Site Request Forgery token
58+ csrfToken : function ( ) {
59+ return $ ( 'meta[name=csrf-token]' ) . attr ( 'content' ) ;
60+ } ,
61+
62+ // URL param that must contain the CSRF token
63+ csrfParam : function ( ) {
64+ return $ ( 'meta[name=csrf-param]' ) . attr ( 'content' ) ;
65+ } ,
66+
5767 // Make sure that every Ajax request sends the CSRF token
5868 CSRFProtection : function ( xhr ) {
59- var token = $ ( 'meta[name="csrf-token"]' ) . attr ( 'content' ) ;
69+ var token = rails . csrfToken ( ) ;
6070 if ( token ) xhr . setRequestHeader ( 'X-CSRF-Token' , token ) ;
6171 } ,
6272
6373 // making sure that all forms have actual up-to-date token(cached forms contain old one)
6474 refreshCSRFTokens : function ( ) {
65- var csrfToken = $ ( 'meta[name=csrf-token]' ) . attr ( 'content' ) ;
66- var csrfParam = $ ( 'meta[name=csrf-param]' ) . attr ( 'content' ) ;
67- $ ( 'form input[name="' + csrfParam + '"]' ) . val ( csrfToken ) ;
75+ $ ( 'form input[name="' + rails . csrfParam ( ) + '"]' ) . val ( rails . csrfToken ( ) ) ;
6876 } ,
6977
7078 // Triggers an event on an element and returns false if the event result is false
You can’t perform that action at this time.
0 commit comments