setLocale(request()->input('lang', 'zh-Hans')); //验证会员授权信息 $clientRoute = request()->route()->getName(); $token=request()->header('Authorization'); if(empty($token)){ $token = request()->input('token',''); } if (!in_array($clientRoute, $this->noAuth)) { if ( empty($token) ) { throw new MemberAuthException('auth.no_key', 401); } $member = RedisDataServer::creatServer()->getData( 'login_' . $token, 'json'); if (empty($member)) { $member = Member::where('token_str', $token)->select(['id', 'address', 'status', 'token_str', 'level_id'])->first(); if(empty($member)){ throw new MemberAuthException('auth.login_error', 401); } } //用户信息缓存30秒 RedisDataServer::creatServer()->setData($token . '_' . $token, $member, 'json', 300); $request->member = $member; }else{ if( $token){ $member = RedisDataServer::creatServer()->getData( 'login_' . $token, 'json'); if (empty($member)) { $member = Member::where('token_str', $token)->where('status',1)->select(['id', 'address', 'status', 'token_str', 'level_id'])->first(); } //用户信息缓存30秒 if($member){ RedisDataServer::creatServer()->setData('login_' . $token, $member, 'json', 300); $request->member = $member; }else{ $request->member = ['id'=>0]; } }else{ $request->member = ['id'=>0]; } } return $next($request); } }