mirror of
https://github.com/elyby/accounts.git
synced 2024-12-28 08:00:25 +05:30
23 lines
501 B
PHP
23 lines
501 B
PHP
<?php
|
|
namespace console\controllers;
|
|
|
|
use common\models\OauthAccessToken;
|
|
use yii\console\Controller;
|
|
|
|
class CleanupController extends Controller {
|
|
|
|
public function actionAccessTokens() {
|
|
$accessTokens = OauthAccessToken::find()
|
|
->andWhere(['<', 'expire_time', time()])
|
|
->each(1000);
|
|
|
|
foreach($accessTokens as $token) {
|
|
/** @var OauthAccessToken $token */
|
|
$token->delete();
|
|
}
|
|
|
|
return self::EXIT_CODE_NORMAL;
|
|
}
|
|
|
|
}
|