| 1234567891011121314151617181920212223242526272829 |
- <?php
- namespace app\controller;
- use app\exceptions\AuthException;
- use think\facade\Cache;
- use think\facade\Db;
- use think\facade\Log;
- class Auth
- {
- //检查token
- public static function checkToken($token,$param){
- try {
- //redis
- $uid = Cache::get($token);
- //如果redis不存在,则提示token不存在
- if(!$uid) return false;
- $userInfo = Db::query("select * from `rrx_user` where `uid`=? limit 1", [$uid]);
- if (!$userInfo) return ['code'=>101];
- return array('data'=>$param,'userInfo'=>$userInfo[0]);
- } catch (\Exception $exception) {
- Log::info('检查token出错'.parseException($exception));
- return array('code'=>500);
- }
- }
- }
|