def check_password(self, raw_password): """ Returns a boolean of whether the raw_password was correct. Handles encryption formats behind the scenes. """ # Backwards-compatibility check. Older passwords won't include the # algorithm or salt. if '$' not in self.password: is_correct = (self.password == get_hexdigest('md5', '', raw_password)) if is_correct: # Convert the password to the new, more secure format. self.set_password(raw_password) self.save() return is_correct return check_password(raw_password, self.password)
def check_password(self, raw_password): """ Returns a boolean of whether the raw_password was correct. Handles encryption formats behind the scenes. """ # Backwards-compatibility check. Older passwords won't include the # algorithm or salt. if '$' not in self.password: is_correct = (self.password == get_hexdigest( 'md5', '', raw_password)) if is_correct: # Convert the password to the new, more secure format. self.set_password(raw_password) self.save() return is_correct return check_password(raw_password, self.password)
def check_password(self, raw_password): """ Returns a boolean of whether the raw_password was correct. Handles encryption formats behind the scenes. """ return check_password(raw_password, self.password)
def test_make_unusable(self): "Check that you can create an unusable password." password = utils.make_password("any", None) self.assertFalse(utils.is_password_usable(password)) self.assertFalse(utils.check_password("foobar", password))
def _test_make_password(self, algo): password = utils.make_password(algo, "foobar") self.assertTrue(utils.is_password_usable(password)) self.assertTrue(utils.check_password("foobar", password))
def check_password(self, raw_password): return check_password(raw_password, self.password)