-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fix constant session regeneration * Add tests for session ID, always regenerating session ID for switching identity
- Loading branch information
Bizley
committed
Dec 29, 2021
1 parent
8c86763
commit 12763a1
Showing
2 changed files
with
52 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -655,9 +655,7 @@ public function switchIdentity($identity, $duration = 0) | |
} | ||
|
||
$session = Yii::$app->getSession(); | ||
if (!YII_ENV_TEST) { | ||
$session->regenerateID(true); | ||
} | ||
$session->regenerateID(true); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
bizley
Member
|
||
$session->remove($this->idParam); | ||
$session->remove($this->authTimeoutParam); | ||
$session->remove($this->authKeyParam); | ||
|
@@ -698,6 +696,9 @@ protected function renewAuthStatus() | |
/* @var $class IdentityInterface */ | ||
$class = $this->identityClass; | ||
$identity = $class::findIdentity($id); | ||
if ($identity === null) { | ||
$this->switchIdentity(null); | ||
} | ||
} | ||
|
||
if ($identity !== null) { | ||
|
@@ -728,10 +729,6 @@ protected function renewAuthStatus() | |
$this->renewIdentityCookie(); | ||
} | ||
} | ||
|
||
if ($this->getIdentity(false) === null) { | ||
$this->switchIdentity(null); | ||
} | ||
} | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This breaks
DbSession
in some cases during tests (not sure about prod)