Switch user login

@param  integer $id
@return boolean
197201
public function switchToUser($id)
    {
        try {
            $user = $this->model->find($id);
            Session::put('original_user', Auth::id());
            Auth::login($user);
            return true;
        } catch (Exception $e) {
            throw new Exception("Error logging in as user", 1);
        }
    }
273111
public function onceUsingId($id)
    {
        $this->setUser($this->provider->retrieveById($id));

        return $this->user instanceof UserContract;
    }
946650
public static function find_by_id($id)
	{
		$hzad = self::oneOrNew($id);

		if (!$hzad->get('authenticator'))
		{
			return false;
		}

		return $hzad;
	}
361407
public function toggleAction($id)
    {
        /** @var Menus_Entity_Table_Menu $table */
        $table = ORM::getTable($this->plugin, 'Menu');
        /** @var Menus_Entity_Menu $menu */
        $menu = $table->find($id);

        if (!is_null($menu))
        {
            $menu->active = !$menu->active;
            $table->update($menu);
        }

        HTTP::redirect(str_replace('&amp;', '&', $this->ui->url()));
    }
747070
public function putActivate($id)
    {
        try
        {
            if ($this->users->activate($id))
            {
                // User activation passed
                return Redirect::route('cpanel.users.index')
                    ->with('success',Lang::get('cpanel::users.activation_success'));
            }
            else
            {
                // User activation failed
                return Redirect::route('cpanel.users.index')
                    ->with('error',Lang::get('cpanel::users.activation_fail'));
            }
        }
        catch (UserNotFoundException $e)
        {
            return Redirect::route('cpanel.users.index')
                ->with('error',$e->getMessage());
        }
    }
1210822
private function toggle($id)
    {
        $Eresus = Eresus_CMS::getLegacyKernel();

        $item = $Eresus->db->selectItem($this->table['name'], "`id`='" . $id . "'");
        $item['active'] = !$item['active'];

        $item = $Eresus->db->escape($item);
        $Eresus->db->updateItem($this->table['name'], $item, "`id`='" . $id . "'");

        HTTP::redirect(Eresus_Kernel::app()->getPage()->url());
    }
832940
public function actionBlock($id)
    {
        $user = $this->findModel($id);
        if ($user->getIsBlocked()) {
            $user->unblock();
            Yii::$app->getSession()->setFlash('success', Yii::t('user', 'User has been unblocked'));
        } else {
            $user->block();
            Yii::$app->getSession()->setFlash('success', Yii::t('user', 'User has been blocked'));
        }
        return $this->redirect(Url::previous('actions-redirect'));
    }
292244
public static function setCurrentID($id)
    {
        $type = self::getType();
        $appID = App::getCurrentID();
        if (array_key_exists($id, self::$instances[$appID][$type])) {
            self::$id = $id;

            return true;
        }

        return false;
    }
577292
public function set(int $id): bool
	{
		if (!$this->isAllowed()) {
			return false;
		}
		$hash = $this->hasher->hash($id);
		$uniqid = uniqid();
		$this->session->setExpiration('5 minutes');
		$this->session->$uniqid = $hash;
		$this->id = $uniqid;
		$this->presenter->redirect($this->redirect);
		return true;
	}
1361830
public function actionBlock($id)
    {
        if ($id == \Yii::$app->user->getId()) {
            \Yii::$app->getSession()->setFlash('danger', \Yii::t('user', 'You can not block your own account'));
        } else {
            $user  = $this->findModel($id);
            $event = $this->getUserEvent($user);
            if ($user->getIsBlocked()) {
                $this->trigger(self::EVENT_BEFORE_UNBLOCK, $event);
                $user->unblock();
                $this->trigger(self::EVENT_AFTER_UNBLOCK, $event);
                \Yii::$app->getSession()->setFlash('success', \Yii::t('user', 'User has been unblocked'));
            } else {
                $this->trigger(self::EVENT_BEFORE_BLOCK, $event);
                $user->block();
                $this->trigger(self::EVENT_AFTER_BLOCK, $event);
                \Yii::$app->getSession()->setFlash('success', \Yii::t('user', 'User has been blocked'));
            }
        }

        return $this->redirect(Url::previous('actions-redirect'));
    }
1148281
public static function setCurrentID($id)
    {
        if (array_key_exists($id, self::$instances)) {
            self::$id = $id;

            return true;
        }

        return false;
    }
199679
public function deactivate($id)
    {
        $user = $this->findById($id);
        $user->activated = 0;
        $user->activated_at = null;
        $user->save();
        $this->event->fire('users.deactivate',array($user));
        return true;
    }
1004977
public function actionActivate($id)
    {
        /* @var $user User */
        $user = $this->findModel($id);
        if ($user->status == User::STATUS_INACTIVE) {
            $user->status = User::STATUS_ACTIVE;
            if ($user->save()) {
                return $this->goHome();
            } else {
                $errors = $user->firstErrors;
                throw new UserException(reset($errors));
            }
        }
        return $this->goHome();
    }
182305
public static function find($id)
    {
        $item = self::getAuthManager()->getRole($id);
        if ($item !== null) {
            return new self($item);
        }
        return null;
    }
1276723
public function setId($id)
    {
        $this->id = (integer)$id;
        $this->hasId = true;

        return $this;
    }
224279
public function isTeamAdmin($id)
    {
        $team = $this->teams->find($id);

        if ($team) {
            return (int) $team->user_id === (int) $this->id;
        }

        return false;
    }
568690
public function delete($id)
    {
        $istance = $this->getById($id);

        if (! $istance)
        {
            return false;
        }

        return $istance->delete();
    }