예제 #1
0
 public function getUserInfo()
 {
     $request = Request::capture();
     $token = $request->input('token');
     $userId = $request->input('userId');
     if ($userId == null) {
         // 如果参数userId为空 则赋值token身份中的userId
         $userId = AuthController::getUserIdByToken($token);
         if ($userId == null) {
             return Utility::response_format(Utility::RESPONSE_CODE_AUTH_ERROR, '', '认证失败');
         }
     }
     // token 认证
     $userInfo = UserAccount::find($userId)->userInfo;
     $userTags = UserAccount::find($userId)->userTags;
     $userInfo['tags'] = $userTags;
     return $userInfo;
 }
예제 #2
0
 public static function getUserIdByToken($token)
 {
     $user = UserAccount::select('id', 'username', 'token')->where('token', $token)->first();
     if ($user == null) {
         return null;
     } else {
         return $user->id;
     }
 }