小程序里用户切换微信号登录,居然获取的openid是一样的?

小程序 文章 2022-04-02 15:20 2798 0 全屏看文

AI助手支持GPT4.0

小程序里用户切换微信号登录,居然获取的openid是一样的?In the applet, the user switches the WeChat account to log in, but the openid obtained is the same?

小程序里用户切换微信号登录,居然获取的openid是一样的?

小程序里在“我的”页面,有一个常规的登录/注销功能,用户可以用微信号来登录。所谓的登录就是getUserProfile来征询用户授权,从而获得用户信息。后台就是简单得用云函数返回event来获取openid。

某用户的微信上有两个号,先用A号登录,返回对应的openid,然后注销,再用另一个B号登录,返回openid,发现openid是一样的。

不是说openid是和微信号相关的吗?不同微信号登录获取的openid应该是不一样的才对啊。

请问各位:

1.这种情况是否正常?或者说我的操作是否有误?

2。如果是正常情况,那如果用户切换微信号登录,我怎么做区分呢?(除了用手机号做用户标识的办法之外)

In the applet, there is a regular login / logout function on the "my" page, and users can log in with micro signal. The so-called login is to ask for user authorization through getuserprofile to obtain user information. The background is simply to use the cloud function to return event to obtain openid. There are two numbers on a user's wechat. First log in with number a, return the corresponding openid, then log out, log in with another number B, return openid, and find that the openid is the same. Isn't openid related to micro signals? The openid obtained by different micro signal login should be different. May I ask you: 1 Is this normal? Or is my operation wrong? 2。 If it is normal, how can I distinguish if the user switches micro signal login? (in addition to the method of using mobile phone number as user identification)

回答:

Bimon:

好的,多谢两位解答,现在我貌似有点头绪了

fuwanhong:

小程序里是切换不了微信登录的,需要在微信app里切换登录账号

brave:

自查代码逻辑。

Bimon:代码逻辑就是用户的登录事件里,直接调云函数获取openid,方式就是简单得返回event里获取。就是这么简单,其他逻辑还没写。现在就是第一步碰到的问题,切换微信号后获取的openid是一样的,试了下拿别的手机的其他微信号,openid不同
brave:每个微信号的openid相对同一个小程序而言是唯一的,没看懂你想表述的,盲猜你把手机号当作唯一标识了,很明确的告诉你并不是。
Bimon:不是的,没有涉及到手机号。就是用户用微信登录这么一个小功能。只不过当用户的微信上有两个微信号时,你用getUserProfile掉起弹窗征询用户授权时,就会有两个微信号供用户选择,用户可以选其一登录,这样切换微信号获取的openid是一样的
brave:getUserProfile 是指你可以用多个 微信头像和昵称 不是说你有两个微信,懂了吗
Bimon:但是那也是两个微信号,不是吗?
brave:不是啊,你想错了
Bimon:额,,这我就有点糊涂了。用户本来就有两个微信号啊,难道因为是属于同一个人,就算作一个微信号了?
brave:微信账号  就是你当前微信app登录那个账号,小程序里授权的这个头像和昵称是说 你授权的时候可以不用自己微信的头像和昵称,相当于自定义,不是说你添加一个自定义的头像昵称,就多了一个微信号。不用再回复了,自己捋一捋,实在没搞懂,就放弃做开发吧。

-EOF-

AI助手支持GPT4.0