add ActivatedFilter
This commit is contained in:
@@ -59,8 +59,14 @@ class LoginController extends RestController
|
||||
|
||||
protected function getOptionalActions()
|
||||
{
|
||||
// user must not be logged in to call this actions
|
||||
return ['login'];
|
||||
}
|
||||
|
||||
protected function getOptionalActivatedActions()
|
||||
{
|
||||
// user must not be activated to call this actions
|
||||
return ['login'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,6 +25,18 @@ class PingController extends RestController
|
||||
Yii::$app->response->setStatusCode( HttpStatus::NO_CONTENT );
|
||||
}
|
||||
|
||||
/** @noinspection PhpUnused */
|
||||
public function actionPingActivated( )
|
||||
{
|
||||
Yii::$app->response->setStatusCode( HttpStatus::NO_CONTENT );
|
||||
}
|
||||
|
||||
/** @noinspection PhpUnused */
|
||||
public function actionPingAuth( )
|
||||
{
|
||||
Yii::$app->response->setStatusCode( HttpStatus::NO_CONTENT );
|
||||
}
|
||||
|
||||
/** @noinspection PhpUnused */
|
||||
public function actionQrcode( )
|
||||
{
|
||||
@@ -38,4 +50,16 @@ class PingController extends RestController
|
||||
}
|
||||
|
||||
|
||||
protected function getOptionalActions()
|
||||
{
|
||||
// user must not be logged in to call this actions
|
||||
return ['ping'];
|
||||
}
|
||||
|
||||
protected function getOptionalActivatedActions()
|
||||
{
|
||||
// user must not be activated to call this actions
|
||||
return ['ping', 'pingActivated'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace mobileapi\controllers;
|
||||
use common\models\Customer;
|
||||
use Exception;
|
||||
use Lcobucci\JWT\Token;
|
||||
use mobileapi\components\ActivatedFilter;
|
||||
use sizeg\jwt\JwtHttpBearerAuth;
|
||||
use Yii;
|
||||
use yii\filters\auth\AuthMethod;
|
||||
@@ -22,6 +23,10 @@ class RestController extends Controller
|
||||
'auth' => [$this, 'auth'],
|
||||
'optional' => $this->getOptionalActions(),
|
||||
];
|
||||
$behaviors['activatedChecker'] = [
|
||||
'class' => ActivatedFilter::class,
|
||||
'optional' => $this->getOptionalActivatedActions()
|
||||
];
|
||||
return $behaviors;
|
||||
}
|
||||
|
||||
@@ -56,5 +61,13 @@ class RestController extends Controller
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the activated filter optional for the actions listed here
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptionalActivatedActions(){
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user