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 ( )

                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 ( )

                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

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