18
18
* In particular, [[User::isGuest]] returns a value indicating whether the current user is a guest or not.
19
19
* Through methods [[login()]] and [[logout()]], you can change the user authentication status.
20
20
*
21
- * User works with a class implementing the [[Identity]] interface . This class implements
21
+ * User works with a class implementing the [[IdentityInterface]] . This class implements
22
22
* the actual user authentication logic and is often backed by a user database table.
23
23
*
24
24
* @property string|integer $id The unique identifier for the user. If null, it means the user is a guest.
25
25
* This property is read-only.
26
- * @property Identity $identity The identity object associated with the currently logged user. Null is
26
+ * @property IdentityInterface $identity The identity object associated with the currently logged user. Null is
27
27
* returned if the user is not logged in (not authenticated).
28
28
* @property boolean $isGuest Whether the current user is a guest. This property is read-only.
29
29
* @property string $returnUrl The URL that the user should be redirected to after login. Note that the type
@@ -128,7 +128,7 @@ public function init()
128
128
129
129
/**
130
130
* Returns the identity object associated with the currently logged user.
131
- * @return Identity the identity object associated with the currently logged user.
131
+ * @return IdentityInterface the identity object associated with the currently logged user.
132
132
* Null is returned if the user is not logged in (not authenticated).
133
133
* @see login
134
134
* @see logout
@@ -140,7 +140,7 @@ public function getIdentity()
140
140
if ($ id === null ) {
141
141
$ this ->_identity = null ;
142
142
} else {
143
- /** @var $class Identity */
143
+ /** @var $class IdentityInterface */
144
144
$ class = $ this ->identityClass ;
145
145
$ this ->_identity = $ class ::findIdentity ($ id );
146
146
}
@@ -156,7 +156,7 @@ public function getIdentity()
156
156
* You should normally update the user identity via methods [[login()]], [[logout()]]
157
157
* or [[switchIdentity()]].
158
158
*
159
- * @param Identity $identity the identity object associated with the currently logged user.
159
+ * @param IdentityInterface $identity the identity object associated with the currently logged user.
160
160
*/
161
161
public function setIdentity ($ identity )
162
162
{
@@ -171,7 +171,7 @@ public function setIdentity($identity)
171
171
* and [[enableAutoLogin]] is true, it will also send out an identity
172
172
* cookie to support cookie-based login.
173
173
*
174
- * @param Identity $identity the user identity (which should already be authenticated)
174
+ * @param IdentityInterface $identity the user identity (which should already be authenticated)
175
175
* @param integer $duration number of seconds that the user can remain in logged-in status.
176
176
* Defaults to 0, meaning login till the user closes the browser or the session is manually destroyed.
177
177
* If greater than 0 and [[enableAutoLogin]] is true, cookie-based login will be supported.
@@ -200,7 +200,7 @@ protected function loginByCookie()
200
200
$ data = json_decode ($ value , true );
201
201
if (count ($ data ) === 3 && isset ($ data [0 ], $ data [1 ], $ data [2 ])) {
202
202
list ($ id , $ authKey , $ duration ) = $ data ;
203
- /** @var $class Identity */
203
+ /** @var $class IdentityInterface */
204
204
$ class = $ this ->identityClass ;
205
205
$ identity = $ class ::findIdentity ($ id );
206
206
if ($ identity !== null && $ identity ->validateAuthKey ($ authKey )) {
@@ -318,7 +318,7 @@ public function loginRequired()
318
318
* The default implementation will trigger the [[EVENT_BEFORE_LOGIN]] event.
319
319
* If you override this method, make sure you call the parent implementation
320
320
* so that the event is triggered.
321
- * @param Identity $identity the user identity information
321
+ * @param IdentityInterface $identity the user identity information
322
322
* @param boolean $cookieBased whether the login is cookie-based
323
323
* @return boolean whether the user should continue to be logged in
324
324
*/
@@ -337,7 +337,7 @@ protected function beforeLogin($identity, $cookieBased)
337
337
* The default implementation will trigger the [[EVENT_AFTER_LOGIN]] event.
338
338
* If you override this method, make sure you call the parent implementation
339
339
* so that the event is triggered.
340
- * @param Identity $identity the user identity information
340
+ * @param IdentityInterface $identity the user identity information
341
341
* @param boolean $cookieBased whether the login is cookie-based
342
342
*/
343
343
protected function afterLogin ($ identity , $ cookieBased )
@@ -353,7 +353,7 @@ protected function afterLogin($identity, $cookieBased)
353
353
* The default implementation will trigger the [[EVENT_BEFORE_LOGOUT]] event.
354
354
* If you override this method, make sure you call the parent implementation
355
355
* so that the event is triggered.
356
- * @param Identity $identity the user identity information
356
+ * @param IdentityInterface $identity the user identity information
357
357
* @return boolean whether the user should continue to be logged out
358
358
*/
359
359
protected function beforeLogout ($ identity )
@@ -370,7 +370,7 @@ protected function beforeLogout($identity)
370
370
* The default implementation will trigger the [[EVENT_AFTER_LOGOUT]] event.
371
371
* If you override this method, make sure you call the parent implementation
372
372
* so that the event is triggered.
373
- * @param Identity $identity the user identity information
373
+ * @param IdentityInterface $identity the user identity information
374
374
*/
375
375
protected function afterLogout ($ identity )
376
376
{
@@ -402,9 +402,9 @@ protected function renewIdentityCookie()
402
402
/**
403
403
* Sends an identity cookie.
404
404
* This method is used when [[enableAutoLogin]] is true.
405
- * It saves [[id]], [[Identity ::getAuthKey()|auth key]], and the duration of cookie-based login
405
+ * It saves [[id]], [[IdentityInterface ::getAuthKey()|auth key]], and the duration of cookie-based login
406
406
* information in the cookie.
407
- * @param Identity $identity
407
+ * @param IdentityInterface $identity
408
408
* @param integer $duration number of seconds that the user can remain in logged-in status.
409
409
* @see loginByCookie
410
410
*/
@@ -430,7 +430,7 @@ protected function sendIdentityCookie($identity, $duration)
430
430
* This method is mainly called by [[login()]], [[logout()]] and [[loginByCookie()]]
431
431
* when the current user needs to be associated with the corresponding identity information.
432
432
*
433
- * @param Identity $identity the identity information to be associated with the current user.
433
+ * @param IdentityInterface $identity the identity information to be associated with the current user.
434
434
* If null, it means switching to be a guest.
435
435
* @param integer $duration number of seconds that the user can remain in logged-in status.
436
436
* This parameter is used only when `$identity` is not null.
@@ -444,7 +444,7 @@ public function switchIdentity($identity, $duration = 0)
444
444
$ this ->setIdentity ($ identity );
445
445
$ session ->remove ($ this ->idVar );
446
446
$ session ->remove ($ this ->authTimeoutVar );
447
- if ($ identity instanceof Identity ) {
447
+ if ($ identity instanceof IdentityInterface ) {
448
448
$ session ->set ($ this ->idVar , $ identity ->getId ());
449
449
if ($ this ->authTimeout !== null ) {
450
450
$ session ->set ($ this ->authTimeoutVar , time () + $ this ->authTimeout );
0 commit comments