mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Refactoring duplicated logic into a method.
This commit is contained in:
parent
ef586d9917
commit
8db0a19585
1 changed files with 19 additions and 13 deletions
|
@ -357,14 +357,8 @@ class CakeSession {
|
|||
*/
|
||||
public static function valid() {
|
||||
if (self::read('Config')) {
|
||||
$validAgent = (
|
||||
Configure::read('Session.checkAgent') === false ||
|
||||
self::$_userAgent == self::read('Config.userAgent')
|
||||
);
|
||||
if ($validAgent && self::$time <= self::read('Config.time')) {
|
||||
if (self::$error === false) {
|
||||
self::$valid = true;
|
||||
}
|
||||
if (self::_validAgentAndTime() && self::$error == false) {
|
||||
self::$valid = true;
|
||||
} else {
|
||||
self::$valid = false;
|
||||
self::__setError(1, 'Session Highjacking Attempted !!!');
|
||||
|
@ -373,6 +367,22 @@ class CakeSession {
|
|||
return self::$valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the user agent is valid and that the session hasn't 'timed out'.
|
||||
* Since timeouts are implemented in CakeSession it checks the current self::$time
|
||||
* against the time the session is set to expire. The User agent is only checked
|
||||
* if Session.checkAgent == true.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected static function _validAgentAndTime() {
|
||||
$validAgent = (
|
||||
Configure::read('Session.checkAgent') === false ||
|
||||
self::$_userAgent == self::read('Config.userAgent')
|
||||
);
|
||||
return ($validAgent && self::$time <= self::read('Config.time'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get / Set the userAgent
|
||||
*
|
||||
|
@ -686,12 +696,8 @@ class CakeSession {
|
|||
protected static function _checkValid() {
|
||||
if (self::read('Config')) {
|
||||
$sessionConfig = Configure::read('Session');
|
||||
$checkAgent = isset($sessionConfig['checkAgent']) && $sessionConfig['checkAgent'] === true;
|
||||
|
||||
if (
|
||||
($checkAgent && self::$_userAgent == self::read('Config.userAgent')) &&
|
||||
self::$time <= self::read('Config.time')
|
||||
) {
|
||||
if (self::_validAgentAndTime()) {
|
||||
$time = self::read('Config.time');
|
||||
self::write('Config.time', self::$sessionTime);
|
||||
if (isset($sessionConfig['autoRegenerate']) && $sessionConfig['autoRegenerate'] === true) {
|
||||
|
|
Loading…
Reference in a new issue