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:
Mateusz Uzdowski 2012-04-26 12:14:27 +12:00 committed by Will Rossiter
parent ca12d54173
commit e11ab5acbf
2 changed files with 18 additions and 1 deletions

View File

@ -304,6 +304,7 @@ class UserDefinedForm_Controller extends Page_Controller {
// load the jquery
Requirements::javascript(SAPPHIRE_DIR .'/thirdparty/jquery/jquery.js');
Requirements::javascript('userforms/thirdparty/jquery-validate/jquery.validate.min.js');
Requirements::javascript('userforms/javascript/UserForm_frontend.js');
}
/**
@ -331,6 +332,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
@ -904,4 +912,4 @@ class UserDefinedForm_SubmittedFormEmail extends Email {
function __construct() {
parent::__construct();
}
}
}

View 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);
});