Class yii\debug\controllers\UserController
Inheritance | yii\debug\controllers\UserController » yii\web\Controller |
---|---|
Available since extension's version | 2.0.10 |
Source Code | https://github.com/yiisoft/yii2-debug/blob/master/src/controllers/UserController.php |
User controller
Public Methods
Method | Description | Defined By |
---|---|---|
actionResetIdentity() | Reset identity, switch to main user | yii\debug\controllers\UserController |
actionSetIdentity() | Set new identity, switch user | yii\debug\controllers\UserController |
beforeAction() | yii\debug\controllers\UserController |
Method Details
Reset identity, switch to main user
public \yii\web\User actionResetIdentity ( ) |
public function actionResetIdentity()
{
$userSwitch = new UserSwitch();
$userSwitch->reset();
return Yii::$app->user;
}
Set new identity, switch user
public \yii\web\User actionSetIdentity ( ) |
public function actionSetIdentity()
{
$user_id = Yii::$app->request->post('user_id');
$userSwitch = new UserSwitch();
$newIdentity = Yii::$app->user->identity->findIdentity($user_id);
$userSwitch->setUserByIdentity($newIdentity);
return Yii::$app->user;
}
public void beforeAction ( $action ) | ||
$action |
public function beforeAction($action)
{
Yii::$app->response->format = Response::FORMAT_JSON;
if (!Yii::$app->session->hasSessionId) {
throw new BadRequestHttpException('Need an active session');
}
return parent::beforeAction($action);
}