Exemplo n.º 1
0
    def doSetUserInfo(cls, rpath):
        isReturn, params = AccountCheck.normal_check(rpath)
        if isReturn:
            return params

        isReturn, params = AccountCheck.set_user_check(rpath, params)
        if isReturn:
            return params

        mo = TyContext.Cls_MsgPack()
        AccountInfo.doSetUserInfo(params, mo)
        return mo
Exemplo n.º 2
0
 def doSnsLogin(cls, rpath):
     # todo 验签
     mo = TyContext.Cls_MsgPack()
     rparams = TyContext.RunHttp.convertArgsToDict()
     rparams['snsId'] = AccountVerify.decode_item(rparams['snsId'])
     snsId = rparams.get('snsId')
     prefix = snsId.split(':')[0]
     isOk = None
     try:
         method = snsv4_login_map.get(prefix)
         if not method:
             isOk = True
         else:
             isOk = method(rparams, snsId)
     except:
         isOk = False
     if not isOk:
         mo.setResult('info', '三方登陆失败')
         mo.setResult('code', 1)
         return mo
     userId = AccountLogin.__find_userid_by_snsid__(snsId)
     is_create = False
     if userId <= 0:
         # 效验该deviceId是否存在第三方sns刷号嫌疑
         isFlag, retMsg = AccountLogin._check_deviceid_sns_forbidden(
             rparams)
         if isFlag:
             mo.setResult('code', AccountConst.CODE_USER_SNS_REG_FAILE)
             mo.setResult('info', retMsg)
             return mo
         rparams['passwd'] = 'ty' + str(random.randint(100000, 999999))
         if snsId.startswith('360'):
             rparams['lang'] = "zh_hans"
         is_create = True
         userId = AccountInfo.createNewUser(rparams,
                                            AccountConst.USER_TYPE_SNS,
                                            False)
         if userId <= 0:
             mo.setResult('code', AccountConst.CODE_USER_GUEST_REG_FAILE)
             mo.setResult('info', '用户账号建立失败')
             return mo
         appId = rparams['appId']
     else:
         rparams['userId'] = userId
         try:
             del rparams['name']
         except:
             pass
         AccountInfo.doSetUserInfo(rparams, mo, False)
     AccountLogin._do_check_login(rparams, userId, mo,
                                  AccountConst.USER_TYPE_SNS, is_create)
     # add to userBindSet
     snsId = rparams.get('snsId')
     AccountModel.add_snsid_to_userbind_set(userId, snsId)
     retMsg = TyContext.Cls_MsgPack()
     if mo.getErrorInfo():
         retMsg.setResult('info', mo.getErrorInfo())
         retMsg.setResult('code', mo.getErrorCode())
         return retMsg
     token = AccountModel.reset_user_token(userId, 'sns')
     retMsg.setResult('token', token)
     retMsg.setResult('code', 0)
     return retMsg
Exemplo n.º 3
0
    def doProcessSnsID(cls, rparams, mo):
        TyContext.ftlog.info(cls.__name__, 'doProcessSnsID->rparams=', rparams)
        snsId = rparams['snsId']
        # 360SDKv1.0.4版本上传的是access_token区分以前360版本上传的code
        # 长度判断是为了兼容360社交登陆
        if snsId.startswith('360'):
            if Account360.doGetUserInfo(rparams, snsId) != True:
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', '360登录验证失败!')
                #                TyContext.BiReport.report_bi_sdk_login(
                #                    TyContext.BIEventId.SDK_LOGIN_BY_SNSID_FAIL, 0,
                #                    rparams['appId'], rparams['clientId'], snsId,
                #                    AccountConst.CODE_USER_SNS_GETINFO_ERROR)
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('ucsid'):
            if AccountUC.doGetUserInfo(rparams, snsId) != True:
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'UC登录验证失败!')
                #                TyContext.BiReport.report_bi_sdk_login(
                #                    TyContext.BIEventId.SDK_LOGIN_BY_SNSID_FAIL, 0,
                #                    rparams['appId'], rparams['clientId'], snsId,
                #                    AccountConst.CODE_USER_SNS_GETINFO_ERROR)
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('qtld:'):
            if not AccountQtld.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'qtld登录验证失败!')
                #                TyContext.BiReport.report_bi_sdk_login(
                #                    TyContext.BIEventId.SDK_LOGIN_BY_SNSID_FAIL, 0,
                #                    rparams['appId'], rparams['clientId'], snsId,
                #                    AccountConst.CODE_USER_SNS_GETINFO_ERROR)
                return
        elif snsId.startswith('wx:'):
            if not AccountWeixin.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'wx登录验证失败!')
                #                TyContext.BiReport.report_bi_sdk_login(
                #                    TyContext.BIEventId.SDK_LOGIN_BY_SNSID_FAIL, 0,
                #                    rparams['appId'], rparams['clientId'], snsId,
                #                    AccountConst.CODE_USER_SNS_GETINFO_ERROR)
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('yy'):
            if not AccountYYgame.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'yy 登陆验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('meizu'):
            if not AccountMeizu.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'meizu 登陆验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('JRTT'):
            if not AccountJRTT.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'jinritoutiao 登陆验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith("fb"):
            if not AccountFaceBook.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'facebook 登陆验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith("xy"):
            if not AccountXY.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'XY苹果助手 登录验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('aisi'):
            if not AccountAiSi.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'AiSi 登陆验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('haimawan'):
            if not AccountHaiMaWan.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', '海马玩 登录验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('youkuh5'):
            if not AccountYouku.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', '优酷登陆验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('huabeidianhua'):
            if not AccountHuabeidianhua.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', '华北电话 登录验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('itools'):
            if not AccountiTools.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'iTools 登陆验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('kuaiyongpingguo'):
            if not AccountKuaiYongPingGuo.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'kuaiyongpingguo 登陆验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('anzhi'):
            if not AccountAnZhi.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', '安智 登录验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('iiapple'):
            if not AccountIIApple.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'iiapple 登陆验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('mumayi'):
            if not AccountMumayi.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'mumayi 登陆验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('pyw'):
            # 朋友玩没有账号验证接口,所有id都认为合法
            if not AccountPengyouwan.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'pengyouwan 登陆验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('m4399'):
            # 朋友玩没有账号验证接口,所有id都认为合法
            if not AccountM4399.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', '4399 登陆验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('coolpad'):
            if not AccountCoolpad.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'coolpad 登陆验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('zhuoyi'):
            if not AccountZhuoyi.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'zhuoyi 登陆验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('jolo'):
            if not AccountJolo.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'jolo 登陆验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('papa'):
            if not AccountPapa.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'papa 登陆验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('kuaiwan'):
            if not AccountKuaiwan.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'kuaiwan 登陆验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('changba'):
            if not AccountChangba.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'changba 登录验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('nubia'):
            if not AccountNubia.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'nubia 登录验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('ysdk'):
            if not AccountYsdk.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', '应用宝YSDK 登录验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('letv'):
            if not AccountLetv.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'Letv 登录验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('bdgame'):
            if not AccountBDGame.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'bdgame 登录验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('yiwan'):
            if not AccountYiwan.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', '益玩 登录验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('jusdk'):
            if not AccountJusdk.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'Jusdk 登录验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('lizi'):
            if not AccountLizi.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', '口袋栗子 登录验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('vivo'):
            if not AccountVivo.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'Vivo 登录验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('lenovo'):
            if not AccountLenovo.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'Lenovo 登录验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('hejiaoyu'):
            if not AccountHejiaoyu.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', '和教育 登录验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('muzhiwan'):
            if not AccountMZWOnline.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', '拇指玩 登录验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('zhangyue'):
            if not AccountZhangyue.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', '掌阅登录验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('vivounion'):
            if not AccountVivounion.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'vivo union登录验证失败!')
                return
        elif snsId.startswith('momo'):
            if not AccountMomo.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', '陌陌登录验证失败!')
                return
            else:
                snsId = rparams['snsId']
        elif snsId.startswith('liebao'):
            if not AccountLiebao.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', '猎豹登陆验证失败!')
                return
            else:
                snsId = rparams['snsId']

        userId = cls.__find_userid_by_snsid__(snsId)
        is_create = False
        if userId <= 0:
            # 效验该deviceId是否存在第三方sns刷号嫌疑
            isFlag, retMsg = cls._check_deviceid_sns_forbidden(rparams)
            if isFlag:
                mo.setResult('code', AccountConst.CODE_USER_SNS_REG_FAILE)
                mo.setResult('info', retMsg)
                return
            rparams['passwd'] = 'ty' + str(random.randint(100000, 999999))
            if snsId.startswith('360'):
                rparams['lang'] = "zh_hans"
            is_create = True
            userId = AccountInfo.createNewUser(rparams, AccountConst.USER_TYPE_SNS, False)
            if userId <= 0:
                mo.setResult('code', AccountConst.CODE_USER_GUEST_REG_FAILE)
                mo.setResult('info', '用户账号建立失败')
                return
            appId = rparams['appId']
            cls.__newaccount_success_callback_(appId, 'newsnsid',
                                               {'appId': appId, 'userId': userId, 'snsId': snsId})
        else:
            rparams['userId'] = userId
            # 2015/2/10 only set name on creating new user
            try:
                del rparams['name']
            except:
                pass
            AccountInfo.doSetUserInfo(rparams, mo, False)
        # 补丁:保存微信openid到用户信息
        # 已经在AccountWeixin中将openid对于的用户信息保存到UserKey数据库中
        if snsId.startswith('wx:'):
            wxopenid = rparams['wxopenid']
            TyContext.RedisUser.execute(userId, 'HSET', 'user:%d' % userId, 'wxopenid', wxopenid)
            TyContext.RedisUserKeys.execute('HSET', 'wxopenid:%s' % wxopenid, 'userId', userId)
        cls._do_check_login(rparams, userId, mo, AccountConst.USER_TYPE_SNS, is_create)
        clientIp = TyContext.UserSession.get_session_client_ip(int(userId))
        TyContext.ftlog.info("UNIVERSAL_LOG_LOGIN", "userId=", userId, 'clientIp=', clientIp, 'version=', 'v3', 'type=',
                             'doProcessSnsID', 'login_params=', rparams)