Commit 851d1538 by Qiang Xue

Fixes #5131: Added `$autoRenew` parameter to `yii\web\User::getIdentity()`

parent 9c375d65
...@@ -218,6 +218,7 @@ Yii Framework 2 Change Log ...@@ -218,6 +218,7 @@ Yii Framework 2 Change Log
- Enh #5089: Added asset debugger panel (arturf, qiangxue) - Enh #5089: Added asset debugger panel (arturf, qiangxue)
- Enh #5117: Added `beforeFilter` and `afterFilter` JS events to `GridView` (kartik-v) - Enh #5117: Added `beforeFilter` and `afterFilter` JS events to `GridView` (kartik-v)
- Enh #5124: Added support to prevent duplicated form submission when using `ActiveForm` (qiangxue) - Enh #5124: Added support to prevent duplicated form submission when using `ActiveForm` (qiangxue)
- Enh #5131: Added `$autoRenew` parameter to `yii\web\User::getIdentity()` (qiangxue)
- Enh: Added support for using sub-queries when building a DB query with `IN` condition (qiangxue) - Enh: Added support for using sub-queries when building a DB query with `IN` condition (qiangxue)
- Enh: Supported adding a new response formatter without the need to reconfigure existing formatters (qiangxue) - Enh: Supported adding a new response formatter without the need to reconfigure existing formatters (qiangxue)
- Enh: Added `yii\web\UrlManager::addRules()` to simplify adding new URL rules (qiangxue) - Enh: Added `yii\web\UrlManager::addRules()` to simplify adding new URL rules (qiangxue)
......
...@@ -161,15 +161,17 @@ class User extends Component ...@@ -161,15 +161,17 @@ class User extends Component
* Returns the identity object associated with the currently logged-in user. * Returns the identity object associated with the currently logged-in user.
* When [[enableSession]] is true, this method may attempt to read the user's authentication data * When [[enableSession]] is true, this method may attempt to read the user's authentication data
* stored in session and reconstruct the corresponding identity object, if it has not done so before. * stored in session and reconstruct the corresponding identity object, if it has not done so before.
* @param boolean $autoRenew whether to automatically renew authentication status if it has not been done so before.
* This is only useful when [[enableSession]] is true.
* @return IdentityInterface|null the identity object associated with the currently logged-in user. * @return IdentityInterface|null the identity object associated with the currently logged-in user.
* `null` is returned if the user is not logged in (not authenticated). * `null` is returned if the user is not logged in (not authenticated).
* @see login() * @see login()
* @see logout() * @see logout()
*/ */
public function getIdentity() public function getIdentity($autoRenew = true)
{ {
if ($this->_identity === false) { if ($this->_identity === false) {
if ($this->enableSession) { if ($this->enableSession && $autoRenew) {
$this->renewAuthStatus(); $this->renewAuthStatus();
} else { } else {
return null; return null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment