作者 lyh

gx

... ... @@ -38,6 +38,7 @@ class BaseController extends Controller
$this->token = $this->request->header('token');
if(!empty($this->token) && !empty(Cache::get($this->token))){
$info = Cache::get($this->token);
Cache::put($this->token, $info, 3600);//更新缓存时间
$this->user = $info;
$this->uid = $info['id'];
//参数处理
... ...
... ... @@ -18,6 +18,7 @@ use App\Models\Service\Service;
use App\Models\Sms\SmsLog;
use App\Models\User\User as UserModel;
use App\Utils\EncryptUtils;
use \Illuminate\Support\Facades\Cache;
use Mrgoon\AliSms\AliSms;
class LoginController extends BaseController
... ... @@ -157,6 +158,19 @@ class LoginController extends BaseController
public function globalSo_v6_login(){
$common = new Common();
$arr = $common->decrypt($this->param['token']);
$this->response('success',Code::SUCCESS,$arr);
if(empty($arr)){
$this->response('登录失败',Code::USER_ERROR);
}
$userModel = new UserModel();
$info = $userModel->read(['mobile'=>$arr['phone']]);
if($info === false){
$this->response('当前用户不存在请联系管理员',Code::USER_ERROR);
}
//生成新token
$token = md5(uniqid().$info['id']);
//存储缓存
$info['token'] = $token;
Cache::add($token,$info,3600);
$this->response('success',Code::SUCCESS,['token'=>$token]);
}
}
... ...
... ... @@ -47,7 +47,7 @@ class UserLoginLogic
$token = md5(uniqid().$info['id']);
//存储缓存
$info['token'] = $token;
Cache::add($token,$info);
Cache::add($token,$info,3600);
//更新用户信息
$rs = $this->model->edit(['token'=>$token],['id'=>$info['id']]);
if($rs === false){
... ...