afa 5 сар өмнө
parent
commit
dfcbcc4ef6

+ 2 - 16
app/api/controller/User.php

@@ -14,23 +14,9 @@ class User extends Base
     protected $noNeedLogin = ['login'];
 
 
-
-
-    public function userinfo(ApiAuthService $authService)
+    public function userinfo()
     {
-      
-        try{
-       
-            
-            dump($this->userinfo);die;
-            $user = $authService->userinfo();
-
-        }catch (ValidateException $e) {
-          
-            return $this->error($e->getError());
-        }catch (\Exception $e){
-            return $this->error($e->getMessage());
-        }
+        $user = $this->userinfo;
         return  $this->success('ok', $user);
     }
 

+ 0 - 1
app/api/service/auth/ApiAuthService.php

@@ -51,7 +51,6 @@ class ApiAuthService
         $user->save();
 
         Cache::set('user_info_'.$user->id, $user->toArray(), Config::get('app.user_login.keepalive_time'));
-
         return ['userinfo'=>$user,'token'=>$token];
     }
 

+ 1 - 20
app/api/service/auth/MysqlAdapter.php

@@ -11,26 +11,7 @@ class MysqlAdapter
 {
     private UserToken $usertoken;
 
-    public function ddddd()
-    {
-       
-        $time=time();
-        $usertoken=UserToken::where(function ($query) use ($token,$time){
-            $token=md5($token);
-            $query->where('token','=',$token);
-            $query->where('expire','>',$time);
-        })->withJoin('user','right')->find();
-        if($usertoken){
-            $auth=Config::get('site.auth');
-            //当登陆时间小于保持登陆时间的一半时,自动续时
-            if($auth['keepalive'] && $usertoken->expire-$time<$auth['keepalive_time']/2){
-                $usertoken->expire=$time+$auth['keepalive_time'];
-                $usertoken->save();
-            }
-            $usertoken->token=$token;
-            $this->usertoken=$usertoken;
-        }
-    }
+  
 
     public  static function userinfo(string $token):int
     {