This comes from [[https://mumunotesss.blogspot.my/2015/06/membuat-login-yii2-dengan-database.html]]\\

Create a login database
<code>
create table login ( 
id int AUTO_INCREMENT, 
username varchar(30), 
password varchar(50), 
authKey varchar(50), 
accessToken varchar(50), 
role varchar(10), 
primary key(id) 
); 
insert into 'login' values ​​('','mursit','bismillah','mursit-12345','mumu2937412912zzzz','Admin');
</code>

Second use gii to create a model for the login table and generate the Login.php in the models folder

Modify the User.php file in the models folder to be
<code>
<?php

namespace app\models;
use app\models\Login;

class User extends \yii\base\BaseObject implements \yii\web\IdentityInterface
{
    public $id;
    public $username;
    public $password;
    public $authKey;
    public $accessToken;
    public $role;

    /**
     * @inheritdoc
     */
    public static function findIdentity($id) 
    { 
// search for user login based on ID and only search 1. 
        $user = Login::findOne($id); 
        if (count($user))
        {
            return new static($user); 
        } 
        return null; 
    } 


    /**
     * @inheritdoc
     */

    public static function findIdentityByAccessToken($token, $type = null) 
    { 
// search for user login based on accessToken and only search 1. 
        $user = Login::find()->where(['accessToken' => $token])->one();
        if (count ($user)) { 
        return new static($user); 
        } 
        return null; 
    } 

    /**
     * Finds user by username
     *
     * @param string $username
     * @return static|null
     */

    public static function findByUsername($username) 
    { 
// search for user login based on username and only search 1. 
        $user = Login::find()->where(['username' => $username])->one();
        if (count($user)) { 
            return new static($user); 
        } 
        return null; 
    } 


    /**
     * @inheritdoc
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @inheritdoc
     */
    public function getAuthKey()
    {
        return $this->authKey;
    }

    /**
     * @inheritdoc
     */
    public function validateAuthKey($authKey)
    {
        return $this->authKey === $authKey;
    }

    /**
     * Validates password
     *
     * @param string $password password to validate
     * @return bool if password provided is valid for current user
     */
    public function validatePassword($password)
    {
        return $this->password === $password;
    }
}

</code>

Login with new credentials as in the database...