def valid_auth_code(): if frappe.session.user != "Guest": return auth_code = frappe.get_request_header("HDB-AuthorizationCode") user = None if auth_code: frappe.logger(__name__).debug( _("HDB-AuthorizationCode as {0}").format(auth_code)) user = IOTHDBSettings.get_on_behalf(auth_code) else: auth_code = frappe.get_request_header("AuthorizationCode") if auth_code: user = frappe.get_value("IOT User Api", {"authorization_code": auth_code}, "user") else: throw(_("Authorization Code/Login is required!")) if not user: throw(_("Authorization Code is incorrect!")) # form dict keeping form_dict = frappe.local.form_dict frappe.set_user(user) frappe.local.form_dict = form_dict
def valid_auth_code(auth_code=None): if 'Guest' != frappe.session.user: return auth_code = auth_code or frappe.get_request_header("HDB-AuthorizationCode") if not auth_code: throw(_("HDB-AuthorizationCode is required in HTTP Header!")) frappe.logger(__name__).debug( _("HDB-AuthorizationCode as {0}").format(auth_code)) user = IOTHDBSettings.get_on_behalf(auth_code) if not user: throw(_("Authorization Code is incorrect!")) # form dict keeping form_dict = frappe.local.form_dict frappe.set_user(user) frappe.local.form_dict = form_dict