t***@hotmail.com
t***@hotmail.com
  • 发布:2021-12-24 15:52
  • 更新:2022-03-23 20:31
  • 阅读:707

【报Bug】uni-quick-login Apple首次登陆user id不会存到userInfo里

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Mac

PC开发环境操作系统版本号: Monterey

HBuilderX类型: Alpha

HBuilderX版本号: 3.3.2

手机系统: iOS

手机系统版本号: iOS 15

手机厂商: 苹果

手机机型: iphone13

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

示例代码:
                uniCloud.callFunction({  
                    name: 'uni-id-cf',  
                    data: {  
                        action,  
                        params  
                    },  
                    success: async ({  
                        result  
                    }) => {  
                        console.log("login-result", result);  
                        if (result.code === 0) {  
                            if (type == 'univerify') {  
                                uni.closeAuthView()  
                            }  
                            uni.hideLoading()  
                            delete result.userInfo.token  

                            // #ifdef MP-WEIXIN  
                            if (type == 'weixin' && !result.userInfo.nickname) {  
                                return this.$refs.userProfile.open(result.uid)  
                            }  
                            // #endif  

                            this.setUserInfo(result.userInfo)  
                            loginSuccess(result)  
                        } else {  
                            uni.showModal({  
                                content: result.msg,  
                                showCancel: false  
                            });  
                        }  
                    },  
                    complete: () => {  
                        uni.hideLoading()  
                    }  
                })

问题就在这行 this.setUserInfo(result.userInfo)
apple 首次登陆后的result里面uid并不在userInfo里.

实例:
{
"code": 0,
"msg": "注册成功",
"token": "x x x",
"tokenExpired": 1642923821777,
"uid": "uid在这个层级",
"type": "register",
"userInfo": {
"nickname": "xxx",
"apple_openid": "xxx",
"dcloud_appid": ["xxx"],
"register_date": 1640331821575,
"register_ip": "192.168.31.177",
"token": "xxx"
},
"openid": "xxx",
"errCode": 0,
"errMsg": "注册成功",
"message": "注册成功"
}

操作步骤:

新用户用apple login首次登陆

预期结果:

新用户用apple login首次登陆后用户id会存放在userInfo里面

实际结果:

新用户用apple login首次登陆后用户id会没存放在userInfo里面, 导致其他功能失效

bug描述:

Apple首次登陆user id不会存到userInfo里

  1. 新用户, 用apple首次登陆之后功能异常, 重新登陆后正常.
  2. debug的结论是因为首次登陆后user id没有存放在userInfo里
  3. 具体code在
2021-12-24 15:52 负责人:DCloud_uniCloud_JSON 分享
已邀请:
t***@hotmail.com

t***@hotmail.com (作者) - like a boss

if (type == 'apple') {  
        result.userInfo._id = result.uid  
}

加上这一行就好了

  • DCloud_uniCloud_JSON

    应当是判断 result.type == "register"

    感谢反馈,1.1.26版本的uni-starter将修复此问题。

    2021-12-29 17:28

该问题目前已经被锁定, 无法添加新回复