12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace App\Http\Middleware;
- use Closure;
- use Illuminate\Support\Facades\Auth;
- /**
- * 公众号检查,获取支付openid
- * Class OfficialCheck
- * @package App\Http\Middleware
- * Auth Zhong
- * Date 2019/2/22
- */
- class OfficialCheck
- {
- /**
- * OfficialCheck constructor.
- */
- public function __construct()
- {
- }
- /**
- * Handle an incoming request.
- *
- * @param \Illuminate\Http\Request $request
- * @param \Closure $next
- * @return mixed
- */
- public function handle($request, Closure $next)
- {
- if (is_weixin() && config('aix.system.pay.wechat.is_on') == 1) {
- if (!$request->session()->has('wechat_pay_openid')) {
- if ($request->route()->getName() != 'mobile.auth.thirdlogin.official.openid') {
- session(['wechat_pay_redirect_url' => $request->fullUrl()]);
- session(['wechat_pay_state' => time()]);
- $wechat_url = "https://open.weixin.qq.com/connect/oauth2/authorize?"
- . "appid=" . config('aix.system.pay.wechat.appid')
- . "&redirect_uri=" . urlencode(route('mobile.auth.thirdlogin.official.openid'))
- . "&response_type=code&scope=snsapi_base&state=" . session('wechat_pay_state') . "#wechat_redirect";
- return redirect($wechat_url);
- }
- }
- }
- return $next($request);
- }
- }
|