|
|
@@ -7,6 +7,7 @@ use App\Module\AppGame\SessionApp;
|
|
|
use App\Module\AppGame\Tools\Protobuf;
|
|
|
use Closure;
|
|
|
use Illuminate\Http\Request;
|
|
|
+use UCore\Helper\Logger;
|
|
|
use Uraus\Kku\Common\RESPONSE_CODE;
|
|
|
use Uraus\Kku\Response;
|
|
|
|
|
|
@@ -28,8 +29,7 @@ class LoginCheck
|
|
|
/**
|
|
|
* @var BaseHandler $handler
|
|
|
*/
|
|
|
- $handler = $request->attributes->get('_handler');
|
|
|
-
|
|
|
+ $handler = $request->attributes->get('_handler');
|
|
|
$need_login = false;
|
|
|
if ($handler && method_exists($handler, 'needLogin') && $handler->needLogin()) {
|
|
|
// 检查是否已登录
|
|
|
@@ -39,6 +39,8 @@ class LoginCheck
|
|
|
|
|
|
// 需要登陆,进行登陆判断
|
|
|
$token = $request->header('token', '');
|
|
|
+ Logger::debug('LoginCheck:' . $token . $need_login);
|
|
|
+
|
|
|
// dump($token);
|
|
|
if (get_class($handler) == 'App\Module\AppGame\Handler\Public\TokenUsefulHandler') {
|
|
|
SessionApp::$session_id = $token;
|
|
|
@@ -49,36 +51,34 @@ class LoginCheck
|
|
|
|
|
|
SessionApp::$session_id = SessionApp::genSessionID();
|
|
|
|
|
|
+ return $next($request);
|
|
|
+ }
|
|
|
+ if (empty($token)) {
|
|
|
+ // token 不合法
|
|
|
+ $response = new Response();
|
|
|
+ $response->setCode(RESPONSE_CODE::REQUEST_ERROR);
|
|
|
+ $response->setMsg('请求错误-Token is import!');
|
|
|
+
|
|
|
+ return \App\Module\AppGame\Tools\Protobuf::response($response);
|
|
|
+
|
|
|
} else {
|
|
|
- if (empty($token)) {
|
|
|
- $token = SessionApp::getSessionId();
|
|
|
- if (get_class($handler) != 'App\Module\AppGame\Handler\Public\TokenHandler') {
|
|
|
- // token 不合法
|
|
|
- $response = new Response();
|
|
|
- $response->setCode(RESPONSE_CODE::REQUEST_ERROR);
|
|
|
- $response->setMsg('请求错误-Token is import!');
|
|
|
-
|
|
|
- return \App\Module\AppGame\Tools\Protobuf::response($response);
|
|
|
- }
|
|
|
- } else {
|
|
|
- // token 不为空
|
|
|
- if (!SessionApp::checktoken($token)) {
|
|
|
- // token 不合法
|
|
|
- $response = new Response();
|
|
|
- $response->setCode(RESPONSE_CODE::REQUEST_ERROR);
|
|
|
- $response->setMsg('请求错误-Token');
|
|
|
-
|
|
|
- return Protobuf::response($response);
|
|
|
- }
|
|
|
- SessionApp::$session_id = $token;
|
|
|
- // 登陆判断
|
|
|
- $uid = \App\Module\AppGame\SessionApp::getUserId();
|
|
|
- // dump($uid);
|
|
|
-
|
|
|
- if ($uid > 0) {
|
|
|
- $handler->user_id = $uid;
|
|
|
- $login_ok = true;
|
|
|
- }
|
|
|
+ // token 不为空
|
|
|
+ if (!SessionApp::checktoken($token)) {
|
|
|
+ // token 不合法
|
|
|
+ $response = new Response();
|
|
|
+ $response->setCode(RESPONSE_CODE::REQUEST_ERROR);
|
|
|
+ $response->setMsg('请求错误-Token');
|
|
|
+
|
|
|
+ return Protobuf::response($response);
|
|
|
+ }
|
|
|
+ SessionApp::$session_id = $token;
|
|
|
+ // 登陆判断
|
|
|
+ $uid = \App\Module\AppGame\SessionApp::getUserId();
|
|
|
+ // dump($uid);
|
|
|
+
|
|
|
+ if ($uid > 0) {
|
|
|
+ $handler->user_id = $uid;
|
|
|
+ $login_ok = true;
|
|
|
}
|
|
|
}
|
|
|
|