config change & bug fix
This commit is contained in:
parent
b9cbb5ca8c
commit
632f50dd9e
|
@ -10,6 +10,10 @@ return [
|
||||||
* 支持的应用配置
|
* 支持的应用配置
|
||||||
*/
|
*/
|
||||||
'apps' => [
|
'apps' => [
|
||||||
|
'op' => [
|
||||||
|
'id' => '100006',
|
||||||
|
'secret' => env('AUTH_OP_SECRET','123456'),
|
||||||
|
],
|
||||||
'erp' => [
|
'erp' => [
|
||||||
'id' => '100009',
|
'id' => '100009',
|
||||||
'secret' => env('AUTH_ERP_SECRET','123456'),
|
'secret' => env('AUTH_ERP_SECRET','123456'),
|
||||||
|
|
17
src/Auth.php
17
src/Auth.php
|
@ -64,7 +64,22 @@ class Auth
|
||||||
}
|
}
|
||||||
switch ($name) {
|
switch ($name) {
|
||||||
case 'erp':
|
case 'erp':
|
||||||
case 'erp_api':
|
case 'erp-api':
|
||||||
|
$this->id = $this->config['apps']['erp']['id'];
|
||||||
|
$this->secret = $this->config['apps']['erp']['secret'];
|
||||||
|
break;
|
||||||
|
case 'ds':
|
||||||
|
case 'ds-api':
|
||||||
|
$this->id = $this->config['apps']['erp']['id'];
|
||||||
|
$this->secret = $this->config['apps']['erp']['secret'];
|
||||||
|
break;
|
||||||
|
case 'crm':
|
||||||
|
case 'crm-api':
|
||||||
|
$this->id = $this->config['apps']['erp']['id'];
|
||||||
|
$this->secret = $this->config['apps']['erp']['secret'];
|
||||||
|
break;
|
||||||
|
case 'op':
|
||||||
|
case 'op-api':
|
||||||
$this->id = $this->config['apps']['erp']['id'];
|
$this->id = $this->config['apps']['erp']['id'];
|
||||||
$this->secret = $this->config['apps']['erp']['secret'];
|
$this->secret = $this->config['apps']['erp']['secret'];
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -16,6 +16,7 @@ trait Controller
|
||||||
{
|
{
|
||||||
$this->guard = $guard;
|
$this->guard = $guard;
|
||||||
app('auth')->shouldUse($guard);
|
app('auth')->shouldUse($guard);
|
||||||
|
app('pd.auth')->choose($guard);
|
||||||
$this->middleware(Authenticate::class);
|
$this->middleware(Authenticate::class);
|
||||||
$this->middleware(CheckRole::class);
|
$this->middleware(CheckRole::class);
|
||||||
|
|
||||||
|
|
|
@ -26,18 +26,9 @@ class PdAuthServiceProvider extends ServiceProvider
|
||||||
|
|
||||||
foreach ($this->app['config']['pdauth']['apps'] as $key => $app) {
|
foreach ($this->app['config']['pdauth']['apps'] as $key => $app) {
|
||||||
$this->app['auth']->viaRequest($key, function (Request $request) use ($key) {
|
$this->app['auth']->viaRequest($key, function (Request $request) use ($key) {
|
||||||
|
|
||||||
$token = $request->header('Authorization', $request->cookie(Authenticate::CookieName));
|
$token = $request->header('Authorization', $request->cookie(Authenticate::CookieName));
|
||||||
|
|
||||||
if ($token) {
|
if ($token) {
|
||||||
try {
|
return app('pd.auth')->choose($key)->getUserInfo($token);
|
||||||
$user = app('pd.auth')->choose($key)->getUserInfo($token);
|
|
||||||
if ($user) {
|
|
||||||
return $user;
|
|
||||||
}
|
|
||||||
} catch (DecryptException $ex) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
@ -71,7 +62,8 @@ class PdAuthServiceProvider extends ServiceProvider
|
||||||
$this->mergeConfigFrom($source, 'pdauth');
|
$this->mergeConfigFrom($source, 'pdauth');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function setupRouter(){
|
protected function setupRouter()
|
||||||
|
{
|
||||||
//添加获取token的路由
|
//添加获取token的路由
|
||||||
$this->app['router']->get('auth/token.json', function (Request $request) {
|
$this->app['router']->get('auth/token.json', function (Request $request) {
|
||||||
$code = $request->input('pd_code');
|
$code = $request->input('pd_code');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user