I implemented it as follows:
config / web.php file
'user' => [
'identityClass' => 'app\models\User',
'enableSession' => false,
'loginUrl' => null,
],
Then I changed the User identity model
class User extends \yii\db\ActiveRecord implements \yii\web\IdentityInterface
{
....
public static function findIdentityByAccessToken($token, $type = null)
{
return static::findOne(['access_token' => $token]);
}
public function updateAccessToken()
{
$this->access_token = Yii::$app->security->generateRandomString();
$this->last_visit_time = date('Y-m-d H:i:s', strtotime('now'));
$this->save();
}
public function getId()
{
return $this->id;
}
public function getAuthKey()
{
}
public function validateAuthKey($authKey)
{
}
...
}
Until I arrived, because after I do not know which controller I should use (if UserControlleror SiteController)
source
share