12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace App\Http\Middleware;
- use Closure;
- use Illuminate\Support\Facades\Auth;
- class OfficialCheck
- {
-
- public function __construct()
- {
- }
-
- 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);
- }
- }
|