mirror of
https://github.com/elyby/accounts.git
synced 2024-11-27 01:02:06 +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;
|
|
}
|
|
|
|
}
|