How to use the smartmin.users.models.is_password_complex function in smartmin

To help you get started, we’ve selected a few smartmin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nyaruka / smartmin / test_runner / blog / tests.py View on Github external
def test_password_is_complex(self):
        # one lower one upper one digit 8 chars
        self.assertTrue(is_password_complex('Ab1.....'))
        self.assertTrue(is_password_complex('   Ab1   '))
        # password is longer than 12 chars
        self.assertTrue(is_password_complex('longer than twelve characters'))
github nyaruka / smartmin / test_runner / blog / tests.py View on Github external
def test_password_is_not_complex(self):
        # length < 8
        self.assertFalse(is_password_complex('only5'))
        # length < 12
        self.assertFalse(is_password_complex('only11chars'))
        # 8 < length < 12, no dig, no cap
        self.assertFalse(is_password_complex('nodignocap'))
        # 8 < length < 12, no cap
        self.assertFalse(is_password_complex('okd1gnocap'))
        # 8 < length < 12, no dig
        self.assertFalse(is_password_complex('nodigokCap'))
        # 8 < length < 12, no low
        self.assertFalse(is_password_complex('OKD1GOKCAP'))
github nyaruka / smartmin / test_runner / blog / tests.py View on Github external
def test_password_is_not_complex(self):
        # length < 8
        self.assertFalse(is_password_complex('only5'))
        # length < 12
        self.assertFalse(is_password_complex('only11chars'))
        # 8 < length < 12, no dig, no cap
        self.assertFalse(is_password_complex('nodignocap'))
        # 8 < length < 12, no cap
        self.assertFalse(is_password_complex('okd1gnocap'))
        # 8 < length < 12, no dig
        self.assertFalse(is_password_complex('nodigokCap'))
        # 8 < length < 12, no low
        self.assertFalse(is_password_complex('OKD1GOKCAP'))
github nyaruka / smartmin / test_runner / blog / tests.py View on Github external
def test_password_is_not_complex(self):
        # length < 8
        self.assertFalse(is_password_complex('only5'))
        # length < 12
        self.assertFalse(is_password_complex('only11chars'))
        # 8 < length < 12, no dig, no cap
        self.assertFalse(is_password_complex('nodignocap'))
        # 8 < length < 12, no cap
        self.assertFalse(is_password_complex('okd1gnocap'))
        # 8 < length < 12, no dig
        self.assertFalse(is_password_complex('nodigokCap'))
        # 8 < length < 12, no low
        self.assertFalse(is_password_complex('OKD1GOKCAP'))
github nyaruka / smartmin / test_runner / blog / tests.py View on Github external
def test_password_is_complex(self):
        # one lower one upper one digit 8 chars
        self.assertTrue(is_password_complex('Ab1.....'))
        self.assertTrue(is_password_complex('   Ab1   '))
        # password is longer than 12 chars
        self.assertTrue(is_password_complex('longer than twelve characters'))
github nyaruka / smartmin / test_runner / blog / tests.py View on Github external
def test_password_is_complex(self):
        # one lower one upper one digit 8 chars
        self.assertTrue(is_password_complex('Ab1.....'))
        self.assertTrue(is_password_complex('   Ab1   '))
        # password is longer than 12 chars
        self.assertTrue(is_password_complex('longer than twelve characters'))
github nyaruka / smartmin / test_runner / blog / tests.py View on Github external
def test_password_is_not_complex(self):
        # length < 8
        self.assertFalse(is_password_complex('only5'))
        # length < 12
        self.assertFalse(is_password_complex('only11chars'))
        # 8 < length < 12, no dig, no cap
        self.assertFalse(is_password_complex('nodignocap'))
        # 8 < length < 12, no cap
        self.assertFalse(is_password_complex('okd1gnocap'))
        # 8 < length < 12, no dig
        self.assertFalse(is_password_complex('nodigokCap'))
        # 8 < length < 12, no low
        self.assertFalse(is_password_complex('OKD1GOKCAP'))
github nyaruka / smartmin / test_runner / blog / tests.py View on Github external
def test_password_is_not_complex(self):
        # length < 8
        self.assertFalse(is_password_complex('only5'))
        # length < 12
        self.assertFalse(is_password_complex('only11chars'))
        # 8 < length < 12, no dig, no cap
        self.assertFalse(is_password_complex('nodignocap'))
        # 8 < length < 12, no cap
        self.assertFalse(is_password_complex('okd1gnocap'))
        # 8 < length < 12, no dig
        self.assertFalse(is_password_complex('nodigokCap'))
        # 8 < length < 12, no low
        self.assertFalse(is_password_complex('OKD1GOKCAP'))
github nyaruka / smartmin / smartmin / users / views.py View on Github external
def clean_confirm_new_password(self):
        if 'new_password' not in self.cleaned_data:
            return None

        if not self.cleaned_data['confirm_new_password'] and self.cleaned_data['new_password']:
            raise forms.ValidationError(_("Confirm your new password by entering it here"))

        if self.cleaned_data['new_password'] != self.cleaned_data['confirm_new_password']:
            raise forms.ValidationError(_("Mismatch between your new password and confirmation, try again"))

        password = self.cleaned_data['new_password']
        if password and not is_password_complex(password):
            raise forms.ValidationError(_("Passwords must have at least 8 characters, including one uppercase, "
                                          "one lowercase and one number"))

        if password and PasswordHistory.is_password_repeat(self.instance, password):
            raise forms.ValidationError(_("You have used this password before in the past year, "
                                          "please use a new password."))

        return self.cleaned_data['new_password']
github nyaruka / smartmin / smartmin / users / views.py View on Github external
def clean_new_password(self):
        password = self.cleaned_data['new_password']

        if password and not is_password_complex(password):
            raise forms.ValidationError(_("Passwords must have at least 8 characters, including one uppercase, "
                                          "one lowercase and one number"))

        if password and PasswordHistory.is_password_repeat(self.instance, password):
            raise forms.ValidationError(_("You have used this password before in the past year, "
                                          "please use a new password."))

        return password