We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<?php /** * Class OAuthAuthenticate: 微信公众号, 企业微信的网页应用。 */ class OAuthAuthenticate { public function handle($request, Closure $next, $account = 'default', $scope = null, $type = 'service') { $isNewSession = false; //保证兼容性 $class = ('work' !== $type) ? 'wechat' : 'work'; $prefix = ('work' !== $type) ? 'official_account' : 'work'; $sessionKey = \sprintf($class.'.oauth_user.%s', $account); $config = config(\sprintf('wechat.'.$prefix.'.%s', $account), []); $officialAccount = app(\sprintf('wechat.'.$prefix.'.%s', $account)); $scope = $scope ?: Arr::get($config, 'oauth.scopes', ['snsapi_base']); if (is_string($scope)) { $scope = array_map('trim', explode(',', $scope)); } $session = session($sessionKey, []); if (!$session) { if ($request->has('code')) { session([$sessionKey => $officialAccount->oauth->user() ?? []]); $isNewSession = true; event(new WeChatUserAuthorized(session($sessionKey), $isNewSession, $account)); return redirect()->to($this->getTargetUrl($request)); } session()->forget($sessionKey); return $officialAccount->oauth->scopes($scope)->redirect($request->fullUrl()); } event(new WeChatUserAuthorized(session($sessionKey), $isNewSession, $account)); return $next($request); } }
原因是 session 没有过期且 sessionKey 不变就不会再次授权;account 一样的情况下,scope 从 'snsapi_base' 换成 'snsapi_userinfo' ,sessionKey 不变,则不会再次授权;
The text was updated successfully, but these errors were encountered:
No branches or pull requests
原因是 session 没有过期且 sessionKey 不变就不会再次授权;account 一样的情况下,scope 从 'snsapi_base' 换成 'snsapi_userinfo' ,sessionKey 不变,则不会再次授权;
The text was updated successfully, but these errors were encountered: