-
-
Notifications
You must be signed in to change notification settings - Fork 504
New issue
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
中间件授权snsapi_base后,不能再次授权snsapi_userinfo #289
Comments
目前解决办法: 登录过程判断是新用户,手动清除用户数据session再跳转注册流程 |
任何授权都是第一次会弹授权界面,所以你根本就不需要切换,一直用 snsapi_userinfo 就好了。 |
做优化?授权弹窗不是这个包能控制的吧?只获取openid不需要授权,可获取全部信息每隔一段时间得重新授权的 |
楼主的意思应该是第一次弹窗用 snsapi_userinfo,获取到全部信息后,后面用户再次访问用 snsapi_base ,静默授权吧,这个时候已经拿到信息了,只需要 openid 确认身份就行了 |
题主的方案是: |
那么根据什么来判断用户是不是首次登陆呢?
ColderWinter <[email protected]>于2019年4月23日 周二下午4:19写道:
… 此问题仍然存在,题主的关于无感登录的需求很实际,这里要是能做一下优化的话,实在是好极了
做优化?授权弹窗不是这个包能控制的吧?只获取openid不需要授权,可获取全部信息每隔一段时间得重新授权的
题主的方案是:
1、用户第一次登录时,使用snsapi_userinfo授权方式(需弹窗)获取用户信息,并注册
2、以后用户来访时,使用snsapi_base获取openid(不需弹窗),实现无感登录
3、这个方案就只需要用户授权一次,以后再也不需要用户授权了
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#289 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AALHOYBUILJJBF6AOBPZ6N3PR3BALANCNFSM4GLIY5BQ>
.
|
比如, |
中间件本来就支持 scope 参数啊?你从 URL 传递不就得了? |
正如题主说的,因为profile页已经使用中间件拿过snsapi_base了,session('wechat.oauth_user.default')已经写入了snsapi_base方式拿到的user_info,跳转到register页时,中间件发现已经有这个session值了,就不会再去拿snsapi_userinfo |
你可以跳转前 清理 session
ColderWinter <[email protected]>于2019年4月23日 周二下午4:29写道:
… 中间件本来就支持 scope 参数啊?你从 URL 传递不就得了?
正如题主说的,因为profile页已经使用中间件拿过snsapi_base了,session('wechat.oauth_user.default')已经写入了snsapi_base方式拿到的user_info,跳转到register页时,中间件发现已经有这个session值了,就不会再去拿snsapi_userinfo
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#289 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AALHOYCNC7JYGDARLWUTL3LPR3CE3ANCNFSM4GLIY5BQ>
.
|
既然解决方案都有了,那就自己撸起袖子加油干了,涉及到判断首次登陆查询数据库这类的,我觉得这已经超出easy-wechat的职责范围了 |
实现并不难,我只是没想明白这个改动带来的收益是什么?反正新用户都会有授权界面,为啥不全用 userinfo 来做?它和 base 的区别是什么?
ALMAS <[email protected]>于2019年4月23日 周二下午4:36写道:
… 此问题仍然存在,题主的关于无感登录的需求很实际,这里要是能做一下优化的话,实在是好极了
做优化?授权弹窗不是这个包能控制的吧?只获取openid不需要授权,可获取全部信息每隔一段时间得重新授权的
题主的方案是:
1、用户第一次登录时,使用snsapi_userinfo授权方式(需弹窗)获取用户信息,并注册
2、以后用户来访时,使用snsapi_base获取openid(不需弹窗),实现无感登录
3、这个方案就只需要用户授权一次,以后再也不需要用户授权了
既然解决方案都有了,那就自己撸起袖子加油干了,涉及到判断首次登陆查询数据库这类的,我觉得这已经超出easy-wechat的职责范围了
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#289 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AALHOYC3VJEJHA73V56PSMDPR3DCLANCNFSM4GLIY5BQ>
.
|
因为用户在session过期后再来访问,会被再次要求授权,对用户造成打扰。而且,静默授权无感登录很好啊。 |
session 过期,和是否显示授权页面完全没有关系,session
是否过期只决定在你的业务系统是否走授权流程,然后是否显示授权那个确认页面是由微信自己的授权系统决定的。
ColderWinter <[email protected]>于2019年4月23日 周二下午4:50写道:
… 类似这个意思吧,如果在中间件里判断一下
[image: middleware]
<https://user-images.githubusercontent.com/3894173/56567594-da8c7680-65e7-11e9-9a44-871c43338f94.jpg>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#289 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AALHOYELIDQ4JWLGXLWQI23PR3EXFANCNFSM4GLIY5BQ>
.
|
我还以为我的issues已经沉了 |
@qq447665722 这么做的目的是什么?减少请求微信 API ? |
以前版本的逻辑不是由snsapi_base升级为snsapi_userinfo时自动重新授权吗? |
我的开发场景是这样的: |
抄了一下以下链接这位哥的代码,发现如果用户自动登录后,再让他授权登录就不会跳转到授权界面了?
https://blog.csdn.net/AIkiller/article/details/79556563
调用了/login,保持session的情况下,再次调用/register就不会跳转授权界面了,怎么才能正常授权跳转?
环境
laravel 5.7
laravel-wechat 4.0.22
The text was updated successfully, but these errors were encountered: