diff --git a/extensions/authclient/AuthAction.php b/extensions/authclient/AuthAction.php index c2f4457..fe37487 100644 --- a/extensions/authclient/AuthAction.php +++ b/extensions/authclient/AuthAction.php @@ -209,7 +209,6 @@ class AuthAction extends Action if ($response instanceof Response) { return $response; } - return $this->redirectSuccess(); } @@ -233,7 +232,6 @@ class AuthAction extends Action ]; $response = Yii::$app->getResponse(); $response->content = Yii::$app->getView()->renderFile($viewFile, $viewData); - return $response; } @@ -247,7 +245,6 @@ class AuthAction extends Action if ($url === null) { $url = $this->getSuccessUrl(); } - return $this->redirect($url); } @@ -261,7 +258,6 @@ class AuthAction extends Action if ($url === null) { $url = $this->getCancelUrl(); } - return $this->redirect($url, false); } @@ -292,7 +288,6 @@ class AuthAction extends Action } } else { $url = $client->buildAuthUrl(); - return Yii::$app->getResponse()->redirect($url); } @@ -325,7 +320,6 @@ class AuthAction extends Action } else { // Upgrade to access token. $client->fetchAccessToken(); - return $this->authSuccess($client); } } @@ -366,7 +360,6 @@ class AuthAction extends Action } } else { $url = $client->buildAuthUrl(); - return Yii::$app->getResponse()->redirect($url); } } diff --git a/extensions/authclient/clients/Live.php b/extensions/authclient/clients/Live.php new file mode 100644 index 0000000..0fb258f --- /dev/null +++ b/extensions/authclient/clients/Live.php @@ -0,0 +1,93 @@ + + * + * Example application configuration: + * + * ~~~ + * 'components' => [ + * 'authClientCollection' => [ + * 'class' => 'yii\authclient\Collection', + * 'clients' => [ + * 'live' => [ + * 'class' => 'yii\authclient\clients\Live', + * 'clientId' => 'live_client_id', + * 'clientSecret' => 'live_client_secret', + * ], + * ], + * ] + * ... + * ] + * ~~~ + * + * @see https://account.live.com/developers/applications + * @see http://msdn.microsoft.com/en-us/library/live/hh243647.aspx + * + * @author Paul Klimov + * @since 2.0 + */ +class Live extends OAuth2 +{ + /** + * @inheritdoc + */ + public $authUrl = 'https://login.live.com/oauth20_authorize.srf'; + /** + * @inheritdoc + */ + public $tokenUrl = 'https://login.live.com/oauth20_token.srf'; + /** + * @inheritdoc + */ + public $apiBaseUrl = 'https://apis.live.net/v5.0'; + + /** + * @inheritdoc + */ + public function init() + { + parent::init(); + if ($this->scope === null) { + $this->scope = implode(',', [ + 'wl.basic', + 'wl.emails', + ]); + } + } + + /** + * @inheritdoc + */ + protected function initUserAttributes() + { + return $this->api('me', 'GET'); + } + + /** + * @inheritdoc + */ + protected function defaultName() + { + return 'live'; + } + + /** + * @inheritdoc + */ + protected function defaultTitle() + { + return 'Live'; + } +} \ No newline at end of file