A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.yiiframework.com/doc/api/2.0/yii-web-identityinterface below:

IdentityInterface, yii\web\IdentityInterface | API Documentation for Yii 2.0

Interface yii\web\IdentityInterface

IdentityInterface is the interface that should be implemented by a class providing identity information.

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;
    }
}

In some situations not all of these methods are required to be implemented. For example, if your application is a pure stateless RESTful application, you would only need to implement findIdentityByAccessToken() and getId() while leaving all other methods with an empty body. Or if your application uses session only authentication, you would need to implement all the methods except findIdentityByAccessToken().

Method Details

Hide inherited methods

Finds an identity by the given ID.

Source code

                public static function findIdentity($id);

            

Finds an identity by the given token.

Source code

                public static function findIdentityByAccessToken($token, $type = null);

            

Returns a key that can be used to check the validity of a given identity ID.

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.

The returned key is used to validate session and auto-login (if yii\web\User::$enableAutoLogin is enabled).

Make sure to invalidate earlier issued authKeys when you implement force user logout, password change and other scenarios, that require forceful access revocation for old sessions.

See also validateAuthKey().

Source code

                public function getAuthKey();

            

Returns an ID that can uniquely identify a user identity.

Source code


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4