예제 #1
0
def execute_cmd(cmd):
    try:
        manage_user()
        method = get_attr(cmd)

        # check if method is whitelisted
        if frappe.session['user'] == 'Guest' and (method
                                                  not in frappe.guest_methods):
            return get_response(message="Not Allowed",
                                args={"http_status_code": 403})
        elif not method in frappe.whitelisted:
            return get_response(message="Not Allowed",
                                args={"http_status_code": 403})
        else:
            args = get_json_request(frappe.local.form_dict.args)
            result = frappe.call(method, args)
            if result:
                if isinstance(result, dict):
                    return get_response(message="Success",
                                        status_code=1,
                                        args=result)
                else:
                    return get_response(message="Success", status_code=1)
            else:
                return get_response(
                    message="Error occured, Please contact administrator")
    except Exception, e:
        raise e
예제 #2
0
def validate_request():
    validate_url()

    args = get_json_request(frappe.local.form_dict.args)
    cmd = frappe.local.form_dict.cmd
    method = cmd.split(".")[2] if cmd != "login" else cmd

    if method != "login":
        validate_user_against_session_id(args)
    validate_request_parameters(method, args)
예제 #3
0
def validate_request():
    validate_url()

    args = get_json_request(frappe.local.form_dict.args)
    cmd = frappe.local.form_dict.cmd
    # method = cmd.split(".")[2] if cmd != "login" else cmd
    method = cmd.split(".")[2] if cmd not in ["login", "logout"] else cmd

    # if method != "login": validate_user_against_session_id(args)
    if method not in ["login", "logout"]:
        validate_user_against_session_id(args)
    validate_request_parameters(method, args)
예제 #4
0
def execute_cmd(cmd):
	try:
		manage_user()
		method = get_attr(cmd)
		
		# check if method is whitelisted
		if frappe.session['user'] == 'Guest' and (method not in frappe.guest_methods):
			return get_response(message="Not Allowed", args={"http_status_code":403})
		elif not method in frappe.whitelisted:
			return get_response(message="Not Allowed", args={"http_status_code":403})
		else:
			args = get_json_request(frappe.local.form_dict.args)
			result = frappe.call(method, args)
			if result:
				if isinstance(result, dict):
					return get_response(message="Success", status_code=1, args=result)
				else:
					return get_response(message="Success", status_code=1)
			else:
				return get_response(message="Error occured, Please contact administrator")
	except Exception, e:
		raise e