config change & bug fix
This commit is contained in:
parent
9ef81c53e3
commit
13637d201f
18
src/Auth.php
18
src/Auth.php
|
@ -54,11 +54,25 @@ class Auth
|
|||
],
|
||||
]);
|
||||
}
|
||||
$this->choose();
|
||||
}
|
||||
|
||||
public function choose($name = null)
|
||||
protected function matchConfigById($id)
|
||||
{
|
||||
foreach ($this->config['apps'] as $name => $app) {
|
||||
if ($app['id'] == $id) {
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function choose($name = null, $id = null)
|
||||
{
|
||||
if ($id) {
|
||||
$name = $this->matchConfigByid($id);
|
||||
$this->choose($name);
|
||||
}
|
||||
|
||||
if (!$name) {
|
||||
$name = env('APP_NAME');
|
||||
}
|
||||
|
|
|
@ -67,7 +67,8 @@ class PdAuthServiceProvider extends ServiceProvider
|
|||
//添加获取token的路由
|
||||
$this->app['router']->get('auth/token.json', function (Request $request) {
|
||||
$code = $request->input('pd_code');
|
||||
$token = app('pd.auth')->getAccessToken($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 response()->json([
|
||||
'code' => 0,
|
||||
|
|
Loading…
Reference in New Issue
Block a user