logout
This commit is contained in:
parent
4b9b69b9b0
commit
b4b7643789
15
src/Auth.php
15
src/Auth.php
|
@ -97,11 +97,6 @@ class Auth
|
|||
$this->id = $this->config['apps']['op']['id'];
|
||||
$this->secret = $this->config['apps']['op']['secret'];
|
||||
break;
|
||||
case 'payment':
|
||||
case 'paymeny_api':
|
||||
$this->id = $this->config['apps']['payment']['id'];
|
||||
$this->secret = $this->config['apps']['payment']['secret'];
|
||||
break;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
@ -141,6 +136,16 @@ class Auth
|
|||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
* @param $token
|
||||
* @return array
|
||||
* @throws \JsonRpc\Exception\RpcServerException
|
||||
*/
|
||||
public function logout($token){
|
||||
return $info = $this->rpc->call('oauth.logout', [$this->id, $this->secret, $token]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户组
|
||||
* @param null $token
|
||||
|
|
|
@ -70,7 +70,15 @@ class PdAuthServiceProvider extends ServiceProvider
|
|||
});
|
||||
|
||||
$this->app['router']->get('api/auth/logout', function (Request $request) {
|
||||
app('pd.auth')->logout();
|
||||
$token = $request->header('Authorization', $request->cookie(Authenticate::CookieName));
|
||||
$cookie = new Cookie(Authenticate::CookieName, '', time());
|
||||
app('pd.auth')->logout($token);
|
||||
return response()->json([
|
||||
'code' => 0,
|
||||
'message' => '',
|
||||
'data' => [],
|
||||
])->withCookie($cookie);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user