Ejemplo n.º 1
0
def validate_mobile_no(mobile_no):
    duplicates = frappe.get_list("User",
                                 filters={"mobile_no": mobile_no},
                                 fields="name")

    if duplicates:
        raise ValidationError("Email or mobile no. already in used.")
Ejemplo n.º 2
0
def validate_email(email):
    duplicates = frappe.get_list("User",
                                 filters={"name": email},
                                 fields="name")

    if duplicates:
        raise ValidationError("Email or mobile no. already in used.")
Ejemplo n.º 3
0
    def validate(self):
        lr = frappe.get_doc("Vehicle Remittance", self.landlord_remittance)

        if lr.docstatus != 1:
            raise ValidationError(
                "Vehicle Remittance must be submitted first before payment.")

        if lr.payment_status == "Settled":
            raise ValidationError(
                "Remittance already settled. Cannot create a Remittance Voucher."
            )

        if self.amount_paid <= 0:
            frappe.throw("Amount Paid is invalid. Cannot be zero or less.")

        if self.net_remittance_amount <= 0:
            frappe.throw(
                "Net Remittance amount is invalid. Cannot be zero or less.")
Ejemplo n.º 4
0
def authenticate(*args, **kwargs):
    token = frappe.get_request_header("Authorization")

    decoded = validate_token(token)
    user = frappe.get_value("User", {
        "email": decoded.get("user"),
        "enabled": 1
    })
    if not user:
        raise ValidationError("Invalid token")

    validate_session(decoded.get("user"), decoded.get("sid"))

    kwargs["decoded"] = decoded
    return args, kwargs
Ejemplo n.º 5
0
	def wrapper(*args, **kwargs):
		# Try to get required headers and decode the body of the request.
		try:
			webhook_topic = frappe.local.request.headers.get('X-Shopify-Topic')
			webhook_hmac	= frappe.local.request.headers.get('X-Shopify-Hmac-Sha256')
			webhook_data	= frappe._dict(json.loads(frappe.local.request.get_data()))
		except:
			raise ValidationError()

		# Verify the HMAC.
		if not _hmac_is_valid(frappe.local.request.get_data(), get_shopify_settings().password, webhook_hmac):
			raise AuthenticationError()

			# Otherwise, set properties on the request object and return.
		frappe.local.request.webhook_topic = webhook_topic
		frappe.local.request.webhook_data  = webhook_data
		kwargs.pop('cmd')

		return f(*args, **kwargs)
Ejemplo n.º 6
0
def validate_password(old_pwd, new_pwd):
    same_passwords = old_pwd == new_pwd
    if same_passwords:
        raise ValidationError(
            "New password cannot be the same with your old password.")