Authentification Pass Through

Hi,

I have an issue with my user authentification:





class User extends \yii\base\Object implements \yii\web\IdentityInterface

{

    public $id;

    public $username;

    public $password;

    public $fullname;

    public $boe;

    public $authKey;

    public $accessToken;

    public $isAdmin;


    /**

    * @inheritdoc

    */

    public static function findIdentity($id)

    {

        if(!isset($_COOKIE['username']))

        {

            return null;

        }

        $user = new user;

        $user->username = $_COOKIE['username'];

        $user->fullname = $_COOKIE['vorname'] . ' ' . $_COOKIE['nachname'];

        $user->boe = $_COOKIE['oe'];

        $user->authKey = $_COOKIE['email'];

        $user->id = $_COOKIE['email'];

        $user->accessToken = $_COOKIE['checksum'];

        //immer funktioniert.. Weil sonst Fehlermeldung!

        return new static($user);

    }


    /**

    * @inheritdoc

    */

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

    {

        if(!isset($_COOKIE['username']))

        {

            return null;

        }

        $user = new user;

        $user->username = $_COOKIE['username'];

        $user->fullname = $_COOKIE['vorname'] . ' ' . $_COOKIE['nachname'];

        $user->boe = $_COOKIE['oe'];

        $user->authKey = $_COOKIE['email'];

        $user->id = $_COOKIE['email'];

        $user->accessToken = $_COOKIE['checksum'];

        //immer funktioniert.. Weil sonst Fehlermeldung!

        return new static($user);

    }


    /**

    * Finds user by username

    *

    * @param string $username

    * @return static|null

    */

    public static function findByUsername($username)

    {

        if(!isset($_COOKIE['username']))

        {

            return null;

        }

        $user = new user;

        $user->username = $_COOKIE['username'];

        $user->fullname = $_COOKIE['vorname'] . ' ' . $_COOKIE['nachname'];

        $user->boe = $_COOKIE['oe'];

        $user->authKey = $_COOKIE['email'];

        $user->id = $_COOKIE['email'];

        $user->accessToken = $_COOKIE['checksum'];

        //immer funktioniert.. Weil sonst Fehlermeldung!

        return new static($user);

    }


    /**

    * @inheritdoc

    */

    public function getId()

    {

        return $this->id;

    }


    /**

    * @inheritdoc

    */

    public function getAuthKey()

    {

        return $this->authKey;

    }


    /**

    * @inheritdoc

    */

    public function validateAuthKey($authKey)

    {

        return $_COOKIE['checksum'] == md5($_COOKIE['email'] . $_COOKIE['nachname'] . $_COOKIE['vorname']);

    }


    /**

    * Validates password

    *

    * @param string $password password to validate

    * @return boolean if password provided is valid for current user

    */

    public function validatePassword($password)

    {

        return true;

    }


    /**

     * [getIsAdmin description]

     * @return boolean if the user is in an administrator

     */

    public function isAdmin()

    {

        return in_array(strtolower($this->username), \Yii::$app->params["adminUsers"]);

    }


}




What I need to achieve, is that: If the user is already existing in the cookies, I wanna start him as already "logged-in" -> do you have an idea, how I can achieve this?

Thank you!