PHP 인터페이스 yii\web\IdentityInterface

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: ~~~ class User extends ActiveRecord implements IdentityInterface { public static function findIdentity($id) { return static::findOne($id); } public static function findIdentityByAccessToken($token, $type = null) { return static::findOne(['access_token' => $token]); } public function getId() { return $this->id; } public function getAuthKey() { return $this->authKey; } public function validateAuthKey($authKey) { return $this->authKey === $authKey; } } ~~~
부터: 2.0
저자: Qiang Xue ([email protected])
파일 보기 프로젝트 열기: yiisoft/yii2 0 사용 예제들

공개 메소드들

메소드 설명
findIdentity ( string | integer $id ) : yii\web\IdentityInterface Finds an identity by the given ID.
findIdentityByAccessToken ( mixed $token, mixed $type = null ) : yii\web\IdentityInterface Finds an identity by the given token.
getAuthKey ( ) : string Returns a key that can be used to check the validity of a given identity ID.
getId ( ) : string | integer Returns an ID that can uniquely identify a user identity.
validateAuthKey ( string $authKey ) : boolean Validates the given auth key.

메소드 상세

findIdentity() 공개 정적인 메소드

Finds an identity by the given ID.
public static findIdentity ( string | integer $id ) : yii\web\IdentityInterface
$id string | integer the ID to be looked for
리턴 yii\web\IdentityInterface the identity object that matches the given ID. Null should be returned if such an identity cannot be found or the identity is not in an active state (disabled, deleted, etc.)

findIdentityByAccessToken() 공개 정적인 메소드

Finds an identity by the given token.
public static findIdentityByAccessToken ( mixed $token, mixed $type = null ) : yii\web\IdentityInterface
$token mixed the token to be looked for
$type mixed the type of the token. The value of this parameter depends on the implementation. For example, [[\yii\filters\auth\HttpBearerAuth]] will set this parameter to be `yii\filters\auth\HttpBearerAuth`.
리턴 yii\web\IdentityInterface the identity object that matches the given token. Null should be returned if such an identity cannot be found or the identity is not in an active state (disabled, deleted, etc.)

getAuthKey() 공개 메소드

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. This is required if [[User::enableAutoLogin]] is enabled.
또한 보기: validateAuthKey()
public getAuthKey ( ) : string
리턴 string a key that is used to check the validity of a given identity ID.

getId() 공개 메소드

Returns an ID that can uniquely identify a user identity.
public getId ( ) : string | integer
리턴 string | integer an ID that uniquely identifies a user identity.

validateAuthKey() 공개 메소드

This is required if [[User::enableAutoLogin]] is enabled.
또한 보기: getAuthKey()
public validateAuthKey ( string $authKey ) : boolean
$authKey string the given auth key
리턴 boolean whether the given auth key is valid.