mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 15:05:42 +00:00
BUGFIX: prevent form from expiring on users - ping regularly.
The form throws a CSRF error if left for too long by itself. This is especially important for long forms. Use local ping function, as the CMS ping returns 403 when BasicAuth is enabled.
This commit is contained in:
parent
e92551b2da
commit
bcd9083d1c
@ -298,6 +298,7 @@ class UserDefinedForm_Controller extends Page_Controller {
|
||||
// load the jquery
|
||||
Requirements::javascript(FRAMEWORK_DIR .'/thirdparty/jquery/jquery.js');
|
||||
Requirements::javascript('userforms/thirdparty/jquery-validate/jquery.validate.min.js');
|
||||
Requirements::javascript('userforms/javascript/UserForm_frontend.js');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -325,6 +326,13 @@ class UserDefinedForm_Controller extends Page_Controller {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Keep the session alive for the user.
|
||||
*/
|
||||
function ping() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the form for the page. Form can be modified by calling {@link updateForm()}
|
||||
* on a UserDefinedForm extension
|
||||
|
9
javascript/UserForm_frontend.js
Normal file
9
javascript/UserForm_frontend.js
Normal file
@ -0,0 +1,9 @@
|
||||
jQuery(function($) {
|
||||
/**
|
||||
* Make sure the form does not expire on the user.
|
||||
*/
|
||||
setInterval(function() {
|
||||
// Ping every 3 mins.
|
||||
$.ajax({url: "UserDefinedForm_Controller/ping"});
|
||||
}, 180*1000);
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user