Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
06ed512463 | ||
![]() |
f7ca7079b1 | ||
![]() |
d5a64ef246 | ||
![]() |
f9a7767e2a | ||
![]() |
95bc222c56 | ||
![]() |
3756ab2851 |
|
@ -14,11 +14,5 @@
|
|||
"require": {
|
||||
"illuminate/support": "^5.5",
|
||||
"paidian/json-rpc": "~1.1"
|
||||
},
|
||||
"repositories": {
|
||||
"php-json-rpc": {
|
||||
"type": "vcs",
|
||||
"url": "git@git.int.haowumc.com:composer/php-json-rpc.git"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
1521
composer.lock
generated
1521
composer.lock
generated
File diff suppressed because it is too large
Load Diff
|
@ -34,5 +34,9 @@ return [
|
|||
'id' => '100005',
|
||||
'secret' => env('AUTH_XIAOKE_SECRET','123456'),
|
||||
],
|
||||
'finance' => [
|
||||
'id' => '100003',
|
||||
'secret' => env('AUTH_FINANCE_SECRET','123456'),
|
||||
],
|
||||
],
|
||||
];
|
|
@ -102,6 +102,15 @@ class Auth
|
|||
$this->id = $this->config['apps']['payment']['id'];
|
||||
$this->secret = $this->config['apps']['payment']['secret'];
|
||||
break;
|
||||
case 'xiaoke':
|
||||
case 'xiaoke_api':
|
||||
$this->id = $this->config['apps']['xiaoke']['id'];
|
||||
$this->secret = $this->config['apps']['xiaoke']['secret'];
|
||||
break;
|
||||
case 'finance':
|
||||
$this->id = $this->config['apps']['finance']['id'];
|
||||
$this->secret = $this->config['apps']['finance']['secret'];
|
||||
break;
|
||||
|
||||
}
|
||||
return $this;
|
||||
|
|
|
@ -41,8 +41,11 @@ class Authenticate
|
|||
{
|
||||
//登录状态检测
|
||||
if ($this->auth->guard($guard)->guest()) {
|
||||
$redirect = $request->input('redirect', $request->header('referer'));
|
||||
// if ($request->isXmlHttpRequest()) {
|
||||
$redirect = $request->input('redirect');
|
||||
if ($request->isXmlHttpRequest()) {
|
||||
if( $redirect == null ){
|
||||
$redirect = $request->header('referer');
|
||||
}
|
||||
return response()->json([
|
||||
'code' => config('pdauth.code.unauthorized', 401),
|
||||
'msg' => 'Unauthorized',
|
||||
|
@ -50,9 +53,12 @@ class Authenticate
|
|||
'url' => app('pd.auth')->connect($redirect),
|
||||
],
|
||||
],401);
|
||||
// } else {
|
||||
// return redirect(app('pd.auth')->connect($redirect));
|
||||
// }
|
||||
} else {
|
||||
if( $redirect == null ){
|
||||
$redirect = $request->getSchemeAndHttpHost()."/api/auth/token.html";
|
||||
}
|
||||
return redirect(app('pd.auth')->connect($redirect));
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace PdAuth;
|
||||
|
||||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use PdAuth\Middleware\Authenticate;
|
||||
|
@ -69,6 +70,14 @@ class PdAuthServiceProvider extends ServiceProvider
|
|||
])->withCookie($cookie);
|
||||
});
|
||||
|
||||
$this->app['router']->get('api/auth/token.html', function (Request $request) {
|
||||
$code = $request->input('pd_code');
|
||||
$id = $request->input('app_id');
|
||||
$token = app('pd.auth')->choose(null, $id)->getAccessToken($code);
|
||||
$cookie = new Cookie(Authenticate::CookieName, $token['access_token'], strtotime($token['expired_at']));
|
||||
return RedirectResponse::create('/')->withCookie($cookie);
|
||||
});
|
||||
|
||||
$this->app['router']->get('api/auth/logout', function (Request $request) {
|
||||
$cookie = new Cookie(Authenticate::CookieName, '', time());
|
||||
return response()->json([
|
||||
|
|
Loading…
Reference in New Issue
Block a user