def get(self, verify_code, user_name, password, type, device_type="", des="", param_sign=None, proxy_sign=None): """ http get 请求 :param verify_code: 验证码 :param user_name: 用户名 :param password: 密码 :param type: 用户类型 :param device_type: 设备类型,对应设备用户 :param des: 描述 :param param_sign:程序签名 :param proxy_sign: 代理签名 :return: {} """ if not user_name\ or not password\ or not type\ or not int(type) in enum.USER_TYPE_LS\ or not device_type in get_device_type(ParamCacher().sm_rpc).keys() if int(type) == enum.DEVICE_USER else False: return {'result': error_code.ERROR_PARAMS_ERROR} # 如果有param_sign,可使用验证param_sign越过验证码 is_privilege = Signer().check_sign(param_sign, verify_code, user_name, password, type, des) \ if param_sign \ else False # 不使用验证码判斷 if type and int(type) in enum.NOT_VERIFY_CODE_USER_LS: is_privilege = True if not is_privilege: if not cookie.check_cookie(self, "register_verify_code", verify_code): logger.error("RegisterHandle check_cookie failed!!!, verify_code:%s\n,param_sign:%s\n, HTTP_SGIN:%s" % (verify_code, param_sign, HTTP_SIGN)) return {'result': error_code.ERROR_VERIFY_CODE_ERROR} rgst_da_tcp = ServiceMgrCacher().get_connection(US_REGISTER_DA, RT_HASH_RING, [user_name]) if get_user_info(rgst_da_tcp, user_name): return {'result': error_code.ERROR_USER_NAME_EXIST} new_jid_dic = UserService().new_jid(user_name, password) params = {"user_name": user_name, "password": password, "des": des, "jid": new_jid_dic['jid'], "jid_pwd": new_jid_dic['password'], "type": type, "device_type": device_type} result = rgst_da_tcp.fetch_async("user_insert", ujson.dumps(params)) if ArgumentParser().args.use_sign: result['sign'] = proxy_sign if proxy_sign else HTTP_SIGN return result
def get(self, verify_code, user_name, password, type, param_sign=None, proxy_sign=None): """ http 请求接口 :param verify_code: 验证码 :param user_name: 用户名 :param password: 密码 :param type: 用户类型 :param param_sign: 程序签名 :param proxy_sign: 代理提供签名 :return:{} """ if not user_name\ or not password: return {'result': error_code.ERROR_PARAMS_ERROR} is_privilege = Signer().check_sign(param_sign, verify_code, user_name, password) \ if param_sign \ else False # 不使用验证码判斷 if type and int(type) in enum.NOT_VERIFY_CODE_USER_LS: is_privilege = True if not is_privilege: if not cookie.check_cookie(self, "verify_code", verify_code): logger.error("CancelHandle check_cookie failed!!!, verify_code:%s\n,param_sign:%s\n, HTTP_SGIN:%s" % (verify_code, param_sign, HTTP_SIGN)) return {'result': error_code.ERROR_VERIFY_CODE_ERROR} rgst_da_tcp = ServiceMgrCacher().get_connection(US_REGISTER_DA, RT_HASH_RING, user_name) user_info = get_user_info(rgst_da_tcp, user_name) if not user_info or user_info['password'] != password: return {'result': error_code.ERROR_USER_NAME_OR_PASSWORD_ERROR} UserService().del_user(user_name) params = {'user_name_ls': [user_name]} result = rgst_da_tcp.fetch_async("user_delete", ujson.dumps(params)) if ArgumentParser().args.use_sign: result['sign'] = proxy_sign if proxy_sign else HTTP_SIGN return result