Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions src/AuthAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,19 @@ class AuthAction extends Action
*/
private $_cancelUrl;

/**
* @var string the ID of user component
* user component ID, which might be set in different module
*/
public $userComponentID;

/**
* @var instance of \yii\web\User
* user component, which is build via [[userComponentID]] property
* if [[userComponentID]] propety not set, then default app user (Yii::$app->getUser()) component will be used
*/
private $_user;


/**
* @param string $url successful URL.
Expand Down Expand Up @@ -165,7 +178,7 @@ public function getCancelUrl()
*/
protected function defaultSuccessUrl()
{
return Yii::$app->getUser()->getReturnUrl();
return $this->_user->getReturnUrl();
}

/**
Expand All @@ -174,7 +187,7 @@ protected function defaultSuccessUrl()
*/
protected function defaultCancelUrl()
{
return Url::to(Yii::$app->getUser()->loginUrl);
return Url::to($this->_user->loginUrl);
}

/**
Expand All @@ -191,6 +204,12 @@ public function run()
}
$client = $collection->getClient($clientId);

$this->_user = (!empty($this->userComponentID) && is_string($this->userComponentID)) ? Yii::createObject(["class" => $this->userComponentID]) : Yii::$app->getUser() ;

if (!($this->_user instanceof \yii\web\User)) {
throw new InvalidConfigException('"' . get_class($this) . '::$user" should be a instance of \yii\web\User.');
}

return $this->auth($client);
}

Expand Down