accounts/api/models/authentication/LogoutForm.php
2018-04-17 23:47:25 +03:00

27 lines
514 B
PHP

<?php
namespace api\models\authentication;
use api\aop\annotations\CollectModelMetrics;
use api\models\base\ApiForm;
use Yii;
class LogoutForm extends ApiForm {
/**
* @CollectModelMetrics(prefix="authentication.logout")
* @return bool
*/
public function logout(): bool {
$component = Yii::$app->user;
$session = $component->getActiveSession();
if ($session === null) {
return true;
}
$session->delete();
return true;
}
}