def doCreateAccount(cls, rparams, mo): TyContext.ftlog.info(cls.__name__, 'doCreateAccount->rparams=', rparams) rparams['passwd'] = 'ty' + str(random.randint(100000, 999999)) loginType = AccountConst.USER_TYPE_DEVICE userId = AccountInfo.createNewUser(rparams, loginType, False) if userId > 0: AccountInfo.fillUserLoginInfoV3(rparams, mo, userId, True, True) TyContext.BiReport.report_bi_sdk_login( AccountConst.LOGIN_SUCC_EVENTIDS[loginType], userId, rparams['appId'], rparams['clientId'], str(rparams.get(AccountConst.LOGIN_BINDID_KEY[loginType], '')), 0, devId=rparams.get('deviceId', '')) else: mo.setResult('code', AccountConst.CODE_USER_GUEST_REG_FAILE) mo.setResult('info', '用户账号建立失败')
def __do_login_double_check__(cls, tuyooId, rparams, mo): doubleUsers = TyContext.Configure.get_global_item_hashset('doublue.user.list', []) devid = rparams.get('deviceId', '') if devid and devid.find('monitor_') >= 0 or devid.find('robot') >= 0: return False if tuyooId in doubleUsers: rparams['passwd'] = 'ty' + str(random.randint(100000, 999999)) loginType = AccountConst.USER_TYPE_DEVICE userId = AccountInfo.createNewUser(rparams, loginType) TyContext.ftlog.info('__do_login_double_check__ old uerid=', tuyooId, ' new userid=', userId) AccountInfo.fillUserLoginInfoV3(rparams, mo, userId, True, True) TyContext.BiReport.report_bi_sdk_login( AccountConst.LOGIN_SUCC_EVENTIDS[loginType], userId, rparams['appId'], rparams['clientId'], str(rparams.get(AccountConst.LOGIN_BINDID_KEY[loginType], '')), 0, devId=rparams.get('deviceId', '')) return True return False
def __do_login_done__(cls, rparams, userId, mo, loginType, is_create=False): if userId <= 0: TyContext.ftlog.error('__do_login_done__ error: userId', userId, 'loginType', loginType, 'is_create', is_create, 'rparams', rparams, 'mo', mo) mo.setResult('code', AccountConst.CODE_USER_PWD_ERROR) mo.setResult('info', '通行证或密码错误,请重新输入!') # TyContext.BiReport.report_bi_sdk_login( # AccountConst.LOGIN_FAIL_EVENTIDS[loginType], userId, # rparams['appId'], rparams['clientId'], # str(rparams.get(AccountConst.LOGIN_BINDID_KEY[loginType], '')), # AccountConst.CODE_USER_NOT_FOUND, devId=rparams.get('deviceId', '')) return if 'passwd' in rparams and not cls.__check_user_passwd__(userId, rparams['passwd']): mo.setResult('code', AccountConst.CODE_USER_PWD_ERROR) mo.setResult('info', '通行证或密码错误,请重新输入!') TyContext.BiReport.report_bi_sdk_login( AccountConst.LOGIN_FAIL_EVENTIDS[loginType], userId, rparams['appId'], rparams['clientId'], str(rparams.get(AccountConst.LOGIN_BINDID_KEY[loginType], '')), AccountConst.CODE_USER_PWD_ERROR, devId=rparams.get('deviceId', '')) return TyContext.UserProps.check_data_update_hall(userId, rparams['appId']) AccountInfo.fillUserLoginInfoV3(rparams, mo, userId, True, is_create) TyContext.BiReport.report_bi_sdk_login( AccountConst.LOGIN_SUCC_EVENTIDS[loginType], userId, rparams['appId'], rparams['clientId'], str(rparams.get(AccountConst.LOGIN_BINDID_KEY[loginType], '')), 0, devId=rparams.get('deviceId', '')) TyContext.BiReport.user_login( rparams['appId'], userId, loginType, rparams['clientId'], TyContext.RunHttp.get_client_ip(), rparams.get('deviceId', ''), params=TyContext.RunHttp.convertArgsToDict(), rpath=TyContext.RunHttp.get_request_path()) try: ReportIOS().on_user_login(userId, rparams) except: TyContext.ftlog.exception()
def doLoginByDevId(cls, rparams, mo): TyContext.ftlog.info(cls.__name__, 'doLoginByDevId->rparams=', rparams) userId = cls.__find_userid_by_devid_map_v3__(rparams['deviceId']) TyContext.ftlog.info(cls.__name__, 'doLoginByDevIdAfter1 userid=', userId, '->rparams=', rparams) if userId <= 0 and rparams.get('mac', ''): macmd5 = rparams.get('macmd5', '') if macmd5: userId = cls.__find_userid_by_devid_map_v2__(macmd5) loginType = AccountConst.USER_TYPE_DEVICE TyContext.ftlog.info(cls.__name__, 'doLoginByDevIdAfter2 userid=', userId, '->rparams=', rparams) if userId > 0: cls._do_check_login(rparams, userId, mo, loginType) else: # 游客初次登陆注册,注册后,返回初次注册的信息 rparams['passwd'] = 'ty' + str(random.randint(100000, 999999)) userId = AccountInfo.createNewUser(rparams, loginType) if userId > 0: AccountInfo.fillUserLoginInfoV3(rparams, mo, userId, True, True) TyContext.BiReport.report_bi_sdk_login( AccountConst.LOGIN_SUCC_EVENTIDS[loginType], userId, rparams['appId'], rparams['clientId'], str(rparams.get(AccountConst.LOGIN_BINDID_KEY[loginType], '')), 0, devId=rparams.get('deviceId', '')) else: if userId == -1: mo.setResult('code', AccountConst.CODE_USER_DEV_REG_FAILE) mo.setResult('info', '您的IP地址异常,暂时无法注册新账号,请电话联系客服:400-8098-000') # 由于客户端没有正确读取info内容,临时加上tips,等新包上线后删掉tips参数 mo.setResult('tips', '您的IP地址异常,暂时无法注册新账号') return mo.setResult('code', AccountConst.CODE_USER_GUEST_REG_FAILE) mo.setResult('info', '设备用户注册失败') clientIp = TyContext.UserSession.get_session_client_ip(int(userId)) TyContext.ftlog.info("UNIVERSAL_LOG_LOGIN", "userId=", userId, 'clientIp=', clientIp, 'version=', 'v3', 'type=', 'doLoginByDevId', 'login_params=', rparams)
def doCheckSmsBind(cls, rparams, mo): bindOrderId = TyContext.RunHttp.getRequestParam('bindOrderId') loginFlag = rparams.get('loginFlag', 0) if bindOrderId is not None: rparams['bindOrderId'] = bindOrderId TyContext.ftlog.info(cls.__name__, 'doCheckSmsBind->rparams=', rparams) if 'bindOrderId' in rparams: bindOrderId = rparams['bindOrderId'] state, userId = TyContext.RedisUserKeys.execute( 'HMGET', 'bindOrder:' + bindOrderId, 'state', 'userId') if state is None: mo.setResult('code', 1) mo.setResult('info', '手机绑定失败,请重试') TyContext.ftlog.error( 'doCheckSmsBind wrong state: no pending bindOrder', bindOrderId, 'rparams', rparams) return if state == AccountConst.MOBILE_BIND_PENDING: mo.setResult('code', 1) mo.setResult('info', '手机绑定进行中,请稍候') return if state == AccountConst.MOBILE_BIND_FAILED: mo.setResult('code', 1) mo.setResult('info', '手机绑定失败,请重试') return if state == AccountConst.MOBILE_BIND_OCCUPIED and loginFlag == 0: mo.setResult('code', AccountConst.MOBILE_BIND_OCCUPIED) # 2 mo.setResult('info', '该手机号已被使用,请绑定其它手机号') return if state == AccountConst.MOBILE_BIND_SUCCESS \ or state == AccountConst.MOBILE_BIND_BOUND \ or state == AccountConst.MOBILE_BIND_OCCUPIED: if len(str(userId)) == 11: userId = TyContext.RedisUserKeys.execute( 'GET', 'mobilemap:' + str(userId)) AccountInfo.fillUserLoginInfoV3(rparams, mo, userId, True, False) TyContext.BiReport.report_bi_sdk_login( AccountConst.LOGIN_SUCC_EVENTIDS[ AccountConst.USER_TYPE_MOBILE], userId, rparams['appId'], rparams['clientId'], mo.getResultStr('mobile'), 0, devId=rparams.get('deviceId', '')) TyContext.BiReport.user_login( rparams['appId'], userId, AccountConst.USER_TYPE_MOBILE, rparams['clientId'], TyContext.RunHttp.get_client_ip(), rparams.get('deviceId', ''), params=TyContext.RunHttp.convertArgsToDict(), rpath=TyContext.RunHttp.get_request_path()) mo.setResult('code', 0) mo.setResult('info', '手机绑定成功') return userId = rparams['userId'] if userId <= 0: mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR) mo.setResult('info', 'userId incorrect') return bindMobile = TyContext.RedisUser.execute(userId, 'HGET', 'user:'******'bindMobile') if bindMobile is None or len(str(bindMobile)) != 11: mo.setResult('code', 1) mo.setResult('info', '手机绑定进行中,请稍候') return mo.setResult('code', 0) mo.setResult('info', '手机绑定成功') AccountInfo.fillUserLoginInfoV3(rparams, mo, userId, True, False) TyContext.BiReport.user_login( rparams['appId'], userId, AccountConst.USER_TYPE_MOBILE, rparams['clientId'], TyContext.RunHttp.get_client_ip(), rparams.get('deviceId', ''), params=TyContext.RunHttp.convertArgsToDict(), rpath=TyContext.RunHttp.get_request_path())