Example #1
0
    def validate(self):
        enable_password_policy = cint(
            self.enable_password_policy) and True or False
        minimum_password_score = cint(
            getattr(self, 'minimum_password_score', 0)) or 0
        if enable_password_policy and minimum_password_score <= 0:
            frappe.throw(_("Please select Minimum Password Score"))
        elif not enable_password_policy:
            self.minimum_password_score = ""

        for key in ("session_expiry", "session_expiry_mobile"):
            if self.get(key):
                parts = self.get(key).split(":")
                if len(parts) != 2 or not (cint(parts[0]) or cint(parts[1])):
                    frappe.throw(
                        _("Session Expiry must be in format {0}").format(
                            "hh:mm"))

        if self.enable_two_factor_auth:
            if self.two_factor_method == 'SMS':
                if not frappe.db.get_value('SMS Settings', None,
                                           'sms_gateway_url'):
                    frappe.throw(
                        _('Please setup SMS before setting it as an authentication method, via SMS Settings'
                          ))
            toggle_two_factor_auth(True, roles=['All'])
        else:
            self.bypass_2fa_for_retricted_ip_users = 0
Example #2
0
    def validate(self):
        enable_password_policy = cint(
            self.enable_password_policy) and True or False
        minimum_password_score = cint(
            getattr(self, "minimum_password_score", 0)) or 0
        if enable_password_policy and minimum_password_score <= 0:
            frappe.throw(_("Please select Minimum Password Score"))
        elif not enable_password_policy:
            self.minimum_password_score = ""

        for key in ("session_expiry", "session_expiry_mobile"):
            if self.get(key):
                parts = self.get(key).split(":")
                if len(parts) != 2 or not (cint(parts[0]) or cint(parts[1])):
                    frappe.throw(
                        _("Session Expiry must be in format {0}").format(
                            "hh:mm"))

        if self.enable_two_factor_auth:
            if self.two_factor_method == "SMS":
                if not frappe.db.get_value("SMS Settings", None,
                                           "sms_gateway_url"):
                    frappe.throw(
                        _("Please setup SMS before setting it as an authentication method, via SMS Settings"
                          ))
            toggle_two_factor_auth(True, roles=["All"])
        else:
            self.bypass_2fa_for_retricted_ip_users = 0
            self.bypass_restrict_ip_check_if_2fa_enabled = 0

        frappe.flags.update_last_reset_password_date = False
        if self.force_user_to_reset_password and not cint(
                frappe.db.get_single_value("System Settings",
                                           "force_user_to_reset_password")):
            frappe.flags.update_last_reset_password_date = True
Example #3
0
	def validate(self):
		enable_password_policy = cint(self.enable_password_policy) and True or False
		minimum_password_score = cint(getattr(self, 'minimum_password_score', 0)) or 0
		if enable_password_policy and minimum_password_score <= 0:
			frappe.throw(_("Please select Minimum Password Score"))
		elif not enable_password_policy:
			self.minimum_password_score = ""

		for key in ("session_expiry", "session_expiry_mobile"):
			if self.get(key):
				parts = self.get(key).split(":")
				if len(parts)!=2 or not (cint(parts[0]) or cint(parts[1])):
					frappe.throw(_("Session Expiry must be in format {0}").format("hh:mm"))

		if self.enable_two_factor_auth:
			if self.two_factor_method=='SMS':
				if not frappe.db.get_value('SMS Settings', None, 'sms_gateway_url'):
					frappe.throw(_('Please setup SMS before setting it as an authentication method, via SMS Settings'))
			toggle_two_factor_auth(True, roles=['All'])
		else:
			self.bypass_2fa_for_retricted_ip_users = 0