Has anyone worked with the yii2-authclient? I am trying to set it up and have most of it working, except that the popup window doesn’t seem to be redirecting properly.
If I return nothing, then it works properly - the popup window closes and the main window redirects home.
If I return a redirection, then the popup window itself redirects to the page and the main window stays the same.
public function successCallback($client)
{
$attributes = $client->getUserAttributes();
// user login or signup comes here
return $this->redirect(["/test/route"]); // popup window redirects
return; // popup window closes and main page redirects home
}
If you return a Response object, then it returns that directly. Meaning that it calls Controller::redirect(). But if you return nothing, then the AuthAction calls its own AuthAction::redirect().
The difference is that the latter uses yii2-authclient/views/redirect.php, which seems to handle the popup window close/redirection. The former, of course, doesn’t use this.
Is this a bug? Or am I just doing something completely wrong?
// yii2-authclient/AuthAction.php
protected function authSuccess($client)
{
if (!is_callable($this->successCallback)) {
throw new InvalidConfigException('"' . get_class($this) . '::successCallback" should be a valid callback.');
}
$response = call_user_func($this->successCallback, $client);
if ($response instanceof Response) {
return $response;
}
return $this->redirectSuccess();
}