web/admin/controllers/UserController.php
public function actionDeregister($id)
    {
        $id = (int)$id;
        if (Yii::$app->user->identity->getID() == $id) {
            throw new ForbiddenHttpException(Yii::t('user', 'You cannot deregister yourself.'));
        }
        $user = $this->getUser($id);
        try {
            $result = $user->deregister();
            if ($result instanceof \Exception) {
                throw $result;
            }
        } catch (\Exception $ex) {
            throw new ServerErrorHttpException($ex->getMessage());
        }
        if ($result !== true) {
            throw new ServerErrorHttpException(Yii::t('user', 'Failed to deregister user.'));
        }
        Yii::$app->session->setFlash(Module::SESSION_KEY_RESULT, Module::RESULT_SUCCESS);
        Yii::$app->session->setFlash(Module::SESSION_KEY_MESSAGE, '(' . $user->getID() . ') ' . $this->deregisterSuccessMessage);
        return $this->redirect(['index']);
    }
public function actionDeregister($id)
    {
        $id = (int)$id;
        if (Yii::$app->user->identity->getID() == $id) {
            throw new ForbiddenHttpException(Yii::t('user', 'You cannot deregister yourself.'));
        }
        $user = $this->getUser($id);
        try {
            $result = $user->deregister();
            if ($result instanceof \Exception) {
                throw $result;
            }
        } catch (\Exception $ex) {
            throw new ServerErrorHttpException($ex->getMessage());
        }
        if ($result !== true) {
            throw new ServerErrorHttpException(Yii::t('user', 'Failed to deregister user.'));
        }
        Yii::$app->session->setFlash(Module::SESSION_KEY_RESULT, Module::RESULT_SUCCESS);
        Yii::$app->session->setFlash(Module::SESSION_KEY_MESSAGE, '(' . $user->getID() . ') ' . $this->deregisterSuccessMessage);
        return $this->redirect(['index']);
    }
public function actionDeregister ( $ id ) { $ id = ( int ) $ id ; if ( Yii :: $ app -> user -> identity -> getID ( ) == $ id ) { throw new ForbiddenHttpException ( Yii :: t ( 'user' , 'You cannot deregister yourself.' ) ) ; } $ user = $ this -> getUser ( $ id ) ; try { $ result = $ user -> deregister ( ) ; if ( $ result instanceof \ Exception ) { throw $ result ; } } catch ( \ Exception $ ex ) { throw new ServerErrorHttpException ( $ ex -> getMessage ( ) ) ; } if ( $ result !== true ) { throw new ServerErrorHttpException ( Yii :: t ( 'user' , 'Failed to deregister user.' ) ) ; } Yii :: $ app -> session -> setFlash ( Module :: SESSION_KEY_RESULT , Module :: RESULT_SUCCESS ) ; Yii :: $ app -> session -> setFlash ( Module :: SESSION_KEY_MESSAGE , '(' . $ user -> getID ( ) . ') ' . $ this -> deregisterSuccessMessage ) ; return $ this -> redirect ( [ 'index' ] ) ; }
Deregister User.
@param string $id User ID.
@return string
@throws ServerErrorHttpException
@throws ForbiddenHttpException
Deregister User .