1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-09 16:26:59 +02:00
This commit is contained in:
Ryan Cramer
2019-04-17 11:11:02 -04:00
parent f30e084e3d
commit 0b98667bc9

View File

@@ -157,6 +157,20 @@ class ProcessLogin extends Process implements ConfigurableModule {
$this->logoutURL = $url;
return $this;
}
/**
* Set cache control headers to prevent caching
*
* Note that PHP already does this, but if someone has overridden PHPs default settings
* then these ones will apply. This is in order to prevent a cached copy of the login form
* from being used since the login form is rendered prior to login session.
*
*/
protected function setCacheHeaders() {
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
}
/**
* Check if login posted and attempt login, otherwise render the login form
@@ -282,7 +296,7 @@ class ProcessLogin extends Process implements ConfigurableModule {
$url = "./?logout=2";
}
$this->session->logout();
$this->session->redirect($url);
$this->session->redirect($url, false);
}
@@ -506,6 +520,13 @@ class ProcessLogin extends Process implements ConfigurableModule {
$this->form->add($f);
}
$s = 'script';
$class = "class=ui-state-error-text";
$jsError = $this->_('Javascript check failed: please enable Javascript to login.');
$cookieError = $this->_('Cookie check failed: please enable cookies to login.');
$this->form->prependMarkup .= "<$s>if(!navigator.cookieEnabled) document.write('<p $class>$cookieError</p>');</$s>";
if($this->isAdmin) $this->form->prependMarkup .= "<no$s><p $class>$jsError</p></no$s>";
return $this->form;
}
@@ -525,6 +546,8 @@ class ProcessLogin extends Process implements ConfigurableModule {
} else if($loggedIn) {
// user is already logged in, do nothing
} else {
// render login form
if($this->isAdmin) $this->setCacheHeaders();
// note the space after 'Login ' is intentional to separate it from the Login button for translation purposes
$this->headline($this->_('Login ')); // Headline for login form page
$this->passField->attr('value', '');
@@ -540,7 +563,7 @@ class ProcessLogin extends Process implements ConfigurableModule {
if(!$this->wire('modules')->isInstalled('InputDetect')) {
/** @var Config $config */
$config = $this->wire('config');
$config->scripts->prepend($config->urls->ProcessLogin . 'what-input.min.js');
$config->scripts->prepend($config->urls('ProcessLogin') . 'what-input.min.js');
}
}
@@ -576,7 +599,7 @@ class ProcessLogin extends Process implements ConfigurableModule {
*/
protected function ___afterLoginRedirect($url = '') {
$url = $this->afterLoginURL($url);
$this->wire('session')->redirect($url);
$this->wire('session')->redirect($url, false);
}
/**