Skip to content

Commit

Permalink
调整命名规则
Browse files Browse the repository at this point in the history
  • Loading branch information
2540463097 committed Jan 15, 2021
1 parent 238d1b8 commit 0e150e1
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class TestController
*/
public function authorization()
{
$auth = new SocialiteAuth(Config::get('aouth.github'));
$auth = new SocialiteAuth(Config::get('oauth.github'));

return $auth->redirect('github');

Expand All @@ -218,7 +218,7 @@ class TestController
*/
public function giteeCallback()
{
$api = new SocialiteAuth(Config::get('aouth.github'));
$api = new SocialiteAuth(Config::get('oauth.github'));

$user = $api->driver('github')->user();

Expand Down Expand Up @@ -286,14 +286,14 @@ class OauthController extends Controller
public function redirect()
{
//return app('SocialiteAuth')->redirect('weibo');
$api = new SocialiteAuth(config('services.aouth.github'));
$api = new SocialiteAuth(config('services.oauth.github'));
return $api->redirect('github');
}
public function auth()
{
// $api = app('SocialiteAuth')->driver('weibo');
//dd($api->user())
$api = new SocialiteAuth(config('services.aouth.github'));
$api = new SocialiteAuth(config('services.oauth.github'));
$user = $api->driver('github')->user();
dd($user);
}
Expand Down
12 changes: 6 additions & 6 deletions src/Api/SocialiteApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,20 @@ public function getAccessToken(): string

public function getUserInfo(): object
{
$aouth = $this->getAccessToken();
$oauth = $this->getAccessToken();

if ('weixin' == $this->deliver) {
return $this->api->getUserInfo(json_decode($aouth, true));
return $this->api->getUserInfo(json_decode($oauth, true));
}
/*elseif ('microsoft' == $this->deliver) {
$access_token = Helpers::getAccessToken($this->deliver, $aouth['$access_token']);
$access_token = Helpers::getAccessToken($this->deliver, $oauth['$access_token']);
$userinfo = $this->api->getUserInfo($access_token);
$userinfo->unionid = $aouth['unionid'];
//$userinfo->openid=$aouth['sub'];
$userinfo->unionid = $oauth['unionid'];
//$userinfo->openid=$oauth['sub'];
return $userinfo;
} */
else {
$access_token = Helpers::getAccessToken($this->deliver, $aouth);
$access_token = Helpers::getAccessToken($this->deliver, $oauth);

return $this->api->getUserInfo($access_token);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Handle/JdOauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function getAccessToken()
return $res->access_token;
}

public function getUserInfo($aouth)
public function getUserInfo($oauth)
{
$user = new \stdClass();
$user->openid = $this->openid;
Expand Down
4 changes: 2 additions & 2 deletions src/Handle/WeiXinOauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public function getAccessToken()
])->getBody()->getContents();
}

public function getUserInfo($aouth)
public function getUserInfo($oauth)
{
$url = $this->userinfo_url.'='.$aouth['access_token'].'&openid='.$aouth['openid'];
$url = $this->userinfo_url.'='.$oauth['access_token'].'&openid='.$oauth['openid'];

return json_decode($this->client->get($url)->getBody()->getContents());
}
Expand Down
16 changes: 8 additions & 8 deletions src/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,31 @@
class Helpers
{
/**
* @param $aouth
* @param $oauth
* @param string $key
*
* @return mixed
*/
public static function getAccessToken($deiver, $aouth, $key = 'access_token')
public static function getAccessToken($deiver, $oauth, $key = 'access_token')
{
switch ($deiver) {
case 'github':
$params = explode('=', $aouth);
$params = explode('=', $oauth);
$access_token = $params[1];
$access_token = explode('&', $access_token);
$access_token = $access_token[0];
return $access_token;
break;
case 'gitlab':
$aouth = json_decode($aouth, true);
return 'Bearer '.$aouth[$key];
$oauth = json_decode($oauth, true);
return 'Bearer '.$oauth[$key];
break;
case 'gitee':
$aouth = json_decode($aouth, true);
return $aouth[$key];
$oauth = json_decode($oauth, true);
return $oauth[$key];
break;
default:
return $aouth;
return $oauth;
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ServiceProvider extends \Illuminate\Support\ServiceProvider
public function register()
{
$this->app->singleton(SocialiteAuth::class, function ($app) {
return new SocialiteAuth(config('services.aouth'));
return new SocialiteAuth(config('services.$oauth'));
});

$this->app->alias(SocialiteAuth::class, 'SocialiteAuth');
Expand Down

0 comments on commit 0e150e1

Please sign in to comment.