run() public method

Runs the action.
public run ( )
 /**
  * @inheritdoc
  */
 public function run()
 {
     if (!empty($_GET['contextData'])) {
         $contextData = Json::decode($_GET['contextData']);
         if (!empty($contextData[$this->clientIdGetParamName])) {
             $clientId = $contextData[$this->clientIdGetParamName];
             /* @var $collection \yii\authclient\Collection */
             $collection = Yii::$app->get($this->clientCollection);
             if (!$collection->hasClient($clientId)) {
                 throw new UnauthorizedHttpException("Unknown auth client '{$clientId}'");
             }
             /** @var OAuth2 $client */
             $client = $collection->getClient($clientId);
             $client->contextData = Json::encode($contextData);
             if (!empty($_GET['sid'])) {
                 $client->sessionId = $_GET['sid'];
             }
             try {
                 return $this->auth($client);
             } catch (\Exception $e) {
                 throw new UnauthorizedHttpException($e->getMessage(), $e->getCode(), $e->getPrevious());
             }
         }
     }
     return parent::run();
 }
Beispiel #2
0
 /**
  * Runs the action.
  */
 public function run()
 {
     try {
         return parent::run();
     } catch (Exception $ex) {
         Yii::$app->session->setFlash('error', $ex->getMessage());
         //Yii::$app->session->setFlash('error', Yii::t('yee/auth', "Authentication error occured."));
         return $this->redirectCancel();
     }
 }
Beispiel #3
0
 /**
  * @inheritdoc
  * @throws InvalidParamException
  */
 public function run()
 {
     $userType = ArrayHelper::getValue($_GET, 'userType', null);
     if (!$userType) {
         return parent::run();
     }
     if ($this->_module->isUserType($userType)) {
         $this->userType = $userType;
         return parent::run();
     } else {
         throw new InvalidParamException("Invalid user type '{$userType}.'");
     }
 }
Beispiel #4
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     try {
         return parent::run();
     } catch (\yii\authclient\InvalidResponseException $e) {
         Yii::$app->session->setFlash('warning', Yii::t('app', 'Invalid response got: {response}. Please try again.', ['response' => $e->getMessage()]));
         $this->controller->layout = $this->controller->module->postRegistrationLayout;
         return $this->controller->render($this->errorView);
     } catch (\Exception $e) {
         Yii::$app->session->setFlash('error', Yii::t('app', $e->getMessage()));
         $this->controller->layout = $this->controller->module->postRegistrationLayout;
         return $this->controller->render($this->errorView);
     }
 }