Class yii\debug\controllers\UserController

Inheritanceyii\debug\controllers\UserController » yii\web\Controller
Available since extension's version2.0.10
Source Code https://github.com/yiisoft/yii2-debug/blob/master/src/controllers/UserController.php

User controller

Method Details

Hide inherited methods

actionResetIdentity() public method

Reset identity, switch to main user

public \yii\web\User actionResetIdentity ( )
throws \yii\base\InvalidConfigException

                public function actionResetIdentity()
{
    $userSwitch = new UserSwitch();
    $userSwitch->reset();
    return Yii::$app->user;
}

            
actionSetIdentity() public method

Set new identity, switch user

public \yii\web\User actionSetIdentity ( )
throws \yii\base\InvalidConfigException

                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;
}

            
beforeAction() public method

public void beforeAction ( $action )
$action
throws \yii\web\BadRequestHttpException

                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);
}