def doSetUserNickName(cls, rparams, mo, needReturn=True): TyContext.ftlog.info(cls.__name__, 'doSetUserNickName->rparams=', rparams, 'needReturn=', needReturn) userId = rparams.get('userId', 0) if userId <= 0: return nickname = rparams.get('name', '') sex = str(rparams.get('sex', '')) datas = [] TyContext.ftlog.debug('nickname=[', nickname, ']') if len(nickname) > 0: newNameIs360Default = Account360.isDefault360Username(nickname) if newNameIs360Default: oldname = TyContext.RedisUser.execute(userId, 'HGET', 'user:'******'name') TyContext.ftlog.debug('nickname=[', nickname, '] oldname=[', oldname, '] sex=[', sex, ']') if not oldname or Account360.isDefault360Username(oldname): if sex not in ('0', '1'): sex = TyContext.RedisUser.execute( userId, 'HGET', 'user:'******'sex') TyContext.ftlog.debug('nickname=[', nickname, '] oldname=[', oldname, '] oldsex=[', sex, ']') nickname = UsernameGenerator.getInstance().generate(sex) # 设定 else: # 保持原名字 nickname = None else: # 设定 pass if nickname != None: datas.append('name') datas.append(nickname) # 修改昵称次数 if needReturn: TyContext.RedisUser.execute(userId, 'HINCRBY', 'user:'******'set_name_sum', 1) if len(datas) > 0: TyContext.RedisUser.execute(userId, 'HMSET', 'user:' + str(userId), *datas) if needReturn: cls.__set_user_info_return__(rparams, mo)
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 doSetUserInfo(cls, rparams, mo, needReturn=True): TyContext.ftlog.info(cls.__name__, 'doSetUserInfo->rparams=', rparams, 'needReturn=', needReturn) userId = rparams.get('userId', 0) if userId <= 0: return nickname = rparams.get('name', '') sex = str(rparams.get('sex', '')) headurl = rparams.get('headurl', '') address = rparams.get('address', '') idcardno = rparams.get('idcardno', '') truename = rparams.get('truename', '') phonenumber = rparams.get('phonenumber', '') lang = rparams.get('lang', None) country = rparams.get('country', None) signature = rparams.get('signature', None) agreeAddFriend = rparams.get('agreeAddFriend', None) email = rparams.get('email', None) datas = [] if len(address) > 0: datas.append('address') datas.append(address) if len(idcardno) > 0: datas.append('idcardno') datas.append(idcardno) if len(truename) > 0: datas.append('truename') datas.append(truename) if len(phonenumber) > 0: datas.append('phonenumber') datas.append(phonenumber) if lang != None: datas.append('lang') datas.append(lang) if country != None: datas.append('country') datas.append(country) if signature != None: datas.append('signature') datas.append(TyContext.KeywordFilter.replace(signature)) if agreeAddFriend != None: if agreeAddFriend == '0' or agreeAddFriend == '1': datas.append('agreeAddFriend') datas.append(int(agreeAddFriend)) if email != None: datas.append('email') datas.append(email) if len(sex) > 0 and sex in ('0', '1'): datas.append('sex') datas.append(sex) oldSex = TyContext.RedisUser.execute(userId, 'HGET', 'user:'******'sex') if oldSex == None: oldSex = sex if int(oldSex) != int(sex): BeautyCertifyService.onUserSexChanged(userId, oldSex, sex) TyContext.ftlog.debug('nickname=[', nickname, ']') if nickname == "LikaiAndZengxinxin" and TyContext.TYGlobal.corporation( ) == "pineapple": pass elif len(nickname) > 0: newNameIs360Default = Account360.isDefault360Username(nickname) if newNameIs360Default: oldname = TyContext.RedisUser.execute(userId, 'HGET', 'user:'******'name') TyContext.ftlog.debug('nickname=[', nickname, '] oldname=[', oldname, '] sex=[', sex, ']') if not oldname or Account360.isDefault360Username(oldname): if sex not in ('0', '1'): sex = TyContext.RedisUser.execute( userId, 'HGET', 'user:'******'sex') TyContext.ftlog.debug('nickname=[', nickname, '] oldname=[', oldname, '] oldsex=[', sex, ']') nickname = UsernameGenerator.getInstance().generate(sex) # 设定 else: # 保持原名字 nickname = None else: # 设定 pass if nickname != None: # 需要根据不同的游戏ID做屏蔽是否不再允许再次更改.(appId 1-19)appId 为 12和15仍可以通过此接口修改名称(大菠萝,海外德州) appId = int(rparams.get('appId', '0')) accessAppId = [1, 2, 3, 4, 5, 6, 7, 8, 12, 15] # h5mod if appId in accessAppId: datas.append('name') datas.append(nickname) # 修改昵称次数 if needReturn: setTimes = TyContext.RedisUser.execute( userId, 'HINCRBY', 'user:'******'set_name_sum', 1) if TyContext.TYGlobal.corporation() == "pineapple": if setTimes > 1: mo.setResult('code', 1) return if len(headurl) > 0: UserPhotoService.setUserPhoto(userId, UserPhoto.PHOTO_TYPE_AVATAR, headurl) TyContext.ftlog.debug('datas', datas, userId) if len(datas) > 0: TyContext.RedisUser.execute(userId, 'HMSET', 'user:'******'clientSystem', '') oldname = TyContext.RedisUser.execute(userId, 'HGET', 'user:'******'name') newname = rparams.get('name', '') if clientSystem == 'Winpc' and oldname != newname: mo.setResult('code', 2) mo.setError(2, '老板,昵称不能随意修改哦。') TyContext.ftlog.debug(cls.__name__, 'doSetUserInfo->mo', mo) else: cls.__set_user_info_return__(rparams, mo)
def createNewUser(cls, params, userType, setDevMap=True): TyContext.ftlog.info(cls.__name__, 'createNewUser start: userType=', userType, 'params=', params) appId = cls.__get_param__(params, 'appId') deviceId = cls.__get_param__(params, 'deviceId') mail = cls.__get_param__(params, 'email') snsId = cls.__get_param__(params, 'snsId') userAccount = cls.__get_param__(params, 'userAccount') mobile = str(cls.__get_param__(params, 'mobile')) clientId = cls.__get_param__(params, 'clientId') if clientId.startswith('robot'): uid = TyContext.RedisMix.execute('INCR', 'global.robotid') if uid > 9999: TyContext.ftlog.error('ERROR toomuch robot users !!!!') uid = 0 uid = str(uid) else: fromip = TyContext.RunHttp.get_client_ip() if cls._is_networkip_restricted(clientId, fromip): return -1 if cls._is_clientip_restricted(clientId, fromip): TyContext.ftlog.info('createNewUser clientid', clientId, 'ip', fromip, 'restricted') return -1 uid = str(TyContext.RedisMix.execute('INCR', 'global.userid')) if int(uid) <= 0: # TyContext.BiReport.report_bi_sdk_login( # AccountConst.CREATE_FAIL_EVENTIDS[userType], 0, appId, clientId, # ['', mail, snsId, mobile][userType], # AccountConst.CODE_USER_NEW_UID_ERROR, devId=deviceId) return 0 datas = { 'password': cls.__get_param__(params, 'passwd'), 'mdevid': deviceId, 'isbind': 1 if userType else 0, 'snsId': snsId, 'name': cls.__get_param__(params, ['name', 'deviceName']), 'source': cls.__get_param__(params, 'source'), 'purl': cls.__get_param__(params, 'purl'), 'address': cls.__get_param__(params, 'address'), 'sex': cls.__get_param__(params, 'sex', '0'), 'state': 0, 'payCount': 0, 'snsinfo': cls.__get_param__(params, 'snsinfo'), 'vip': 0, 'dayang': 0, 'idcardno': cls.__get_param__(params, 'idcardno'), 'phonenumber': cls.__get_param__(params, 'phonenumber'), 'truename': cls.__get_param__(params, 'truename'), 'detect_phonenumber': cls.__get_param__(params, 'detect_phonenumber'), 'email': mail, 'createTime': datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f'), 'userAccount': userAccount, 'clientId': clientId, 'appId': appId, 'bindMobile': mobile, 'mac': cls.__get_param__(params, 'mac'), 'idfa': cls.__get_param__(params, 'idfa'), 'imei': cls.__get_param__(params, 'imei'), 'imsi': cls.__get_param__(params, 'imsi', ''), 'androidId': cls.__get_param__(params, 'androidId'), 'uuid': cls.__get_param__(params, 'uuid'), 'userId': uid, 'sendMeGift': 1, "lang": cls.__get_param__(params, 'lang'), "country": "", "signature": "", "agreeAddFriend": 1, "email": "", } if datas['sex'] == '': datas['sex'] = '0' if datas['purl'] == '': datas['purl'] = UserPhotoService.getDefaultUserAvatar( int(uid), clientId) is_winpc = cls.__get_param__(params, 'clientSystem').lower() == 'winpc' name = datas['name'] if not name or Account360.isDefault360Username(name) or is_winpc: genUsername = UsernameGenerator.getInstance().generate( datas['sex']) if genUsername: datas['name'] = genUsername # 设置用户数据 udkv = [] for k, v in datas.items(): udkv.append(k) udkv.append(v) # TyContext.ftlog.debug('createNewUser->values=', udkv) TyContext.RedisUser.execute(uid, 'HMSET', 'user:'******'SET', 'snsidmap:' + snsId, uid) # 设置反查索引, MAIL if len(mail) > 0: TyContext.RedisUserKeys.execute('SET', 'mailmap:' + mail, uid) # 设置反查索引, userName if len(userAccount) > 0: TyContext.RedisUserKeys.execute('SET', 'accountmap:' + userAccount, uid) # 设置反查索引, mobile if len(mobile) > 0: TyContext.RedisUserKeys.execute('SET', 'mobilemap:' + mobile, uid) # 设置反查索引, DevId if setDevMap and len( deviceId ) > 0 and deviceId != '528c8e6cd4a3c6598999a0e9df15ad32': TyContext.RedisUserKeys.execute('SET', 'devidmap3:' + deviceId, uid) cls.updateUserSessionInfo(appId, uid, params) TyContext.BiReport.user_register( appId, uid, userType, clientId, TyContext.RunHttp.get_client_ip(), deviceId, params=TyContext.RunHttp.convertArgsToDict(), rpath=TyContext.RunHttp.get_request_path()) TyContext.BiReport.report_bi_sdk_login( AccountConst.CREATE_SUCC_EVENTIDS[userType], uid, appId, clientId, ['', mail, snsId, mobile][userType], 0, devId=deviceId) # Report.recoderUserNew( appId, uid, userType) TyContext.UserProps.check_data_update_hall(int(uid), appId, True) AdvertiseService.on_user_created(int(uid)) return int(uid)
def doSetUserInfo(cls, rparams, mo, needReturn=True): TyContext.ftlog.info(cls.__name__, 'doSetUserInfo->rparams=', rparams, 'needReturn=', needReturn) userId = rparams.get('userId', 0) if userId <= 0: return nickname = rparams.get('name', '') sex = str(rparams.get('sex', '')) headurl = rparams.get('headurl', '') address = rparams.get('address', '') idcardno = rparams.get('idcardno', '') truename = rparams.get('truename', '') phonenumber = rparams.get('phonenumber', '') lang = rparams.get('lang', None) country = rparams.get('country', None) signature = rparams.get('signature', None) agreeAddFriend = rparams.get('agreeAddFriend', None) email = rparams.get('email', None) snsinfo = rparams.get('snsinfo', None) datas = [] if len(address) > 0: datas.append('address') datas.append(address) if len(idcardno) > 0: datas.append('idcardno') datas.append(idcardno) if len(truename) > 0: datas.append('truename') datas.append(truename) if len(phonenumber) > 0: datas.append('phonenumber') datas.append(phonenumber) if lang != None: datas.append('lang') datas.append(lang) if country != None: datas.append('country') datas.append(country) if signature != None: datas.append('signature') datas.append(TyContext.KeywordFilter.replace(signature)) if agreeAddFriend != None: if agreeAddFriend == '0' or agreeAddFriend == '1': datas.append('agreeAddFriend') datas.append(int(agreeAddFriend)) if email != None: datas.append('email') datas.append(email) if snsinfo != None: datas.append('snsinfo') datas.append(snsinfo) if len(sex) > 0 and sex in ('0', '1'): datas.append('sex') datas.append(sex) oldSex = TyContext.RedisUser.execute(userId, 'HGET', 'user:'******'sex') if oldSex == None: oldSex = sex if int(oldSex) != int(sex): BeautyCertifyService.onUserSexChanged(userId, oldSex, sex) TyContext.ftlog.debug('nickname=[', nickname, ']') oldname = TyContext.RedisUser.execute(userId, 'HGET', 'user:'******'name') ''' if nickname == "LikaiAndZengxinxin" and TyContext.TYGlobal.corporation() == "pineapple": pass ''' if len(nickname) > 0: newNameIs360Default = Account360.isDefault360Username(nickname) if newNameIs360Default: TyContext.ftlog.debug('nickname=[', nickname, '] oldname=[', oldname, '] sex=[', sex, ']') if not oldname or Account360.isDefault360Username(oldname): if sex not in ('0', '1'): sex = TyContext.RedisUser.execute( userId, 'HGET', 'user:'******'sex') TyContext.ftlog.debug('nickname=[', nickname, '] oldname=[', oldname, '] oldsex=[', sex, ']') nickname = UsernameGenerator.getInstance().generate(sex) # 设定 else: # 保持原名字 nickname = None else: # 设定 pass if nickname != None: # todo for 104 test add by tcz mo_tmp = TyContext.MsgPack() UsernameGenerator.change_old_user_name(nickname, userId, mo_tmp) if str(mo_tmp.getResult('code')) != '0': mo.setResult('code', mo_tmp.getResult('code')) mo.setResult('info', mo_tmp.getResult(('info'))) return datas.append('name') datas.append(nickname) # 需要根据不同的游戏ID做屏蔽是否不再允许再次更改.(appId 1-19)appId 为 12和15仍可以通过此接口修改名称(大菠萝,海外德州) accessAppId = TyContext.Configure.get_global_item_json( 'change_nickname_appId', [12, 15]) appId = int(rparams.get('appId', '0')) if not appId in accessAppId and oldname != nickname and needReturn: TyContext.RedisUser.execute(userId, 'HINCRBY', 'user:'******'set_name_sum', 1) if len(headurl) > 0: UserPhotoService.setUserPhoto(userId, UserPhoto.PHOTO_TYPE_AVATAR, headurl) if len(datas) > 0: TyContext.RedisUser.execute(userId, 'HMSET', 'user:' + str(userId), *datas) if needReturn: cls.__set_user_info_return__(rparams, mo)
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)