You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					82 lines
				
				2.3 KiB
			
		
		
			
		
	
	
					82 lines
				
				2.3 KiB
			| 
											13 years ago
										 | <?php
 | ||
|  | /**
 | ||
|  |  * @link http://www.yiiframework.com/
 | ||
|  |  * @copyright Copyright (c) 2008 Yii Software LLC
 | ||
|  |  * @license http://www.yiiframework.com/license/
 | ||
|  |  */
 | ||
|  | 
 | ||
|  | namespace yii\web;
 | ||
|  | 
 | ||
|  | /**
 | ||
| 
											12 years ago
										 |  * IdentityInterface is the interface that should be implemented by a class providing identity information.
 | ||
| 
											13 years ago
										 |  *
 | ||
|  |  * This interface can typically be implemented by a user model class. For example, the following
 | ||
|  |  * code shows how to implement this interface by a User ActiveRecord class:
 | ||
|  |  *
 | ||
|  |  * ~~~
 | ||
| 
											12 years ago
										 |  * class User extends ActiveRecord implements IdentityInterface
 | ||
| 
											13 years ago
										 |  * {
 | ||
|  |  *     public static function findIdentity($id)
 | ||
|  |  *     {
 | ||
|  |  *         return static::find($id);
 | ||
|  |  *     }
 | ||
|  |  *
 | ||
|  |  *     public function getId()
 | ||
|  |  *     {
 | ||
|  |  *         return $this->id;
 | ||
|  |  *     }
 | ||
|  |  *
 | ||
|  |  *     public function getAuthKey()
 | ||
|  |  *     {
 | ||
|  |  *         return $this->authKey;
 | ||
|  |  *     }
 | ||
|  |  *
 | ||
|  |  *     public function validateAuthKey($authKey)
 | ||
|  |  *     {
 | ||
|  |  *         return $this->authKey === $authKey;
 | ||
|  |  *     }
 | ||
|  |  * }
 | ||
|  |  * ~~~
 | ||
| 
											13 years ago
										 |  *
 | ||
|  |  * @author Qiang Xue <qiang.xue@gmail.com>
 | ||
|  |  * @since 2.0
 | ||
|  |  */
 | ||
| 
											12 years ago
										 | interface IdentityInterface
 | ||
| 
											13 years ago
										 | {
 | ||
|  | 	/**
 | ||
| 
											13 years ago
										 | 	 * Finds an identity by the given ID.
 | ||
|  | 	 * @param string|integer $id the ID to be looked for
 | ||
| 
											12 years ago
										 | 	 * @return IdentityInterface the identity object that matches the given ID.
 | ||
| 
											13 years ago
										 | 	 * Null should be returned if such an identity cannot be found
 | ||
|  | 	 * or the identity is not in an active state (disabled, deleted, etc.)
 | ||
|  | 	 */
 | ||
|  | 	public static function findIdentity($id);
 | ||
|  | 	/**
 | ||
| 
											13 years ago
										 | 	 * Returns an ID that can uniquely identify a user identity.
 | ||
| 
											13 years ago
										 | 	 * @return string|integer an ID that uniquely identifies a user identity.
 | ||
| 
											13 years ago
										 | 	 */
 | ||
|  | 	public function getId();
 | ||
|  | 	/**
 | ||
|  | 	 * Returns a key that can be used to check the validity of a given identity ID.
 | ||
| 
											13 years ago
										 | 	 *
 | ||
|  | 	 * The key should be unique for each individual user, and should be persistent
 | ||
|  | 	 * so that it can be used to check the validity of the user identity.
 | ||
|  | 	 *
 | ||
|  | 	 * The space of such keys should be big enough to defeat potential identity attacks.
 | ||
| 
											13 years ago
										 | 	 *
 | ||
|  | 	 * This is required if [[User::enableAutoLogin]] is enabled.
 | ||
| 
											13 years ago
										 | 	 * @return string a key that is used to check the validity of a given identity ID.
 | ||
| 
											13 years ago
										 | 	 * @see validateAuthKey()
 | ||
|  | 	 */
 | ||
|  | 	public function getAuthKey();
 | ||
|  | 	/**
 | ||
|  | 	 * Validates the given auth key.
 | ||
| 
											13 years ago
										 | 	 *
 | ||
|  | 	 * This is required if [[User::enableAutoLogin]] is enabled.
 | ||
| 
											13 years ago
										 | 	 * @param string $authKey the given auth key
 | ||
|  | 	 * @return boolean whether the given auth key is valid.
 | ||
|  | 	 * @see getAuthKey()
 | ||
|  | 	 */
 | ||
|  | 	public function validateAuthKey($authKey);
 | ||
| 
											13 years ago
										 | }
 |