def doBindBySnsId(cls, rparams, mo): TyContext.ftlog.info(cls.__name__, 'doBindBySnsId->rparams=', rparams) userId = rparams['userId'] snsId = rparams['snsId'] if snsId.startswith('360'): if Account360.doGetUserInfo(rparams, snsId) != True: mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR) mo.setResult('info', '360登录验证失败!') return else: snsId = rparams['snsId'] # 绑定过程,不改变用户昵称 if 'name' in rparams: del rparams['name'] 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'] userIdBound = TyContext.RedisUserKeys.execute('GET', 'snsidmap:' + snsId) if userIdBound: TyContext.MySqlSwap.checkUserDate(userIdBound) AccountHelper.restore_avatar_verify_set(userIdBound) mo.setResult('code', 0) mo.setResult('info', '绑定成功') mo.setResult('binduserstyle', 2) AccountLogin.__do_login_done__(rparams, userIdBound, mo, AccountConst.USER_TYPE_SNS) return # V3版一个tyid可以绑定多个snsId TyContext.MySqlSwap.checkUserDate(userId) AccountHelper.restore_avatar_verify_set(userId) TyContext.RedisUser.execute( userId, 'HMSET', 'user:'******'snsId', snsId, 'isbind', AccountConst.USER_TYPE_SNS, 'bindTime', datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')) TyContext.RedisUserKeys.execute('SET', 'snsidmap:' + snsId, userId) mo.setResult('code', 0) mo.setResult('binduserstyle', 1) mo.setResult('info', '绑定成功') AccountLogin.__do_login_done__(rparams, userId, mo, AccountConst.USER_TYPE_SNS) cls.__bind_success_callback_(rparams['appId'], 'bindsnsid', { 'appId': rparams['appId'], 'userId': userId, 'snsId': snsId })
def doLoginBySnsID(cls, rparams, mo): TyContext.ftlog.info(cls.__name__, 'doLoginBySnsID->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登录验证失败!') return else: snsId = rparams['snsId'] userId = cls.__find_userid_by_snsid__(snsId) # TyContext.ftlog.info(cls.__name__, 'doLoginBySnsID->userId=', userId, 'rparams=', rparams) cls._do_check_login(rparams, userId, mo, AccountConst.USER_TYPE_SNS)
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)