2016-07-17 22:08:04 +05:30
|
|
|
<?php
|
2019-12-21 04:56:06 +05:30
|
|
|
declare(strict_types=1);
|
|
|
|
|
2016-07-17 22:08:04 +05:30
|
|
|
namespace api\models\authentication;
|
|
|
|
|
2017-11-19 21:02:51 +05:30
|
|
|
use api\aop\annotations\CollectModelMetrics;
|
2016-07-17 22:08:04 +05:30
|
|
|
use api\models\base\ApiForm;
|
2017-11-19 21:02:51 +05:30
|
|
|
use Yii;
|
2016-07-17 22:08:04 +05:30
|
|
|
|
|
|
|
class LogoutForm extends ApiForm {
|
|
|
|
|
2017-11-19 21:02:51 +05:30
|
|
|
/**
|
|
|
|
* @CollectModelMetrics(prefix="authentication.logout")
|
|
|
|
* @return bool
|
|
|
|
*/
|
2018-04-18 02:17:25 +05:30
|
|
|
public function logout(): bool {
|
2017-11-19 21:02:51 +05:30
|
|
|
$component = Yii::$app->user;
|
2016-07-17 22:08:04 +05:30
|
|
|
$session = $component->getActiveSession();
|
|
|
|
if ($session === null) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$session->delete();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|