def validate_password_confirmation(self, data): password = data.get('password') confirm = data.get('confirm') target_user = get_current_user() user_id = data.get('id') if is_admin(): if password: data['password'] = hash_password(data['password']) return data else: if password and (confirm is None): raise ValidationError('Please confirm your current password', field_names=['confirm']) if password and confirm: test = verify_password(plaintext=confirm, ciphertext=target_user.password) if test is True: data['password'] = hash_password(data['password']) return data else: raise ValidationError('Your previous password is incorrect', field_names=['confirm'])
def __init__(self, name, **kwargs): self.name = name self.password = hash_password(kwargs['password']) self.email = kwargs['email'] self.TYPE = kwargs['type'] self.website = kwargs['website'] if 'website' in kwargs else None self.affiliation = kwargs[ 'affiliation'] if 'affiliation' in kwargs else None self.country = kwargs['country'] if 'country' in kwargs else None self.hidden = kwargs['hidden'] if 'hidden' in kwargs else 1 self.verified = kwargs['verified'] if 'verified' in kwargs else 0 self.banned = kwargs['banned'] if 'banned' in kwargs else 0
def validate_password(self, key, plaintext): return hash_password(str(plaintext))
def validate_password(self, key, plaintext): from CTFd.utils.crypto import hash_password return hash_password(str(plaintext))
def __init__(self, **kwargs): super(Teams, self).__init__(**kwargs) if kwargs.get('password'): self.password = hash_password(str(kwargs['password']))
def test_hash_password(): assert hash_password("asdf").startswith("$bcrypt-sha256")
def test_hash_password(): assert hash_password('asdf').startswith('$bcrypt-sha256')