<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-

from .base import db, BaseMixin


class User(db.Model, BaseMixin):

    __tablename__ = "users"

    name = db.Column(db.String(200), nullable=False)
    email = db.Column(db.String(300), unique=True)

    def __repr__(self):
        return self.name<commit_msg>Addded bcrypt password hashing to user model<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-

from passlib.hash import bcrypt

from .base import db, BaseMixin


class User(db.Model, BaseMixin):
    __tablename__ = 'users'

    name = db.Column(db.String(300), nullable=False)
    email = db.Column(db.String(300), unique=True, nullable=False)
    password = db.Column(db.String, nullable=False)

    def set_password(self, password, rounds=12):
        """Hash a plain text password and set the encrypted version against
        this instance.
        :param password: hashable str
        :param rounds: Specify the number of rounds bcrypt will perform
        :returns: None
        """
        self.password = bcrypt.encrypt(password, rounds=rounds)

    def verify_password(self, password):
        """Verify an encrypted password using ``password`` as a salt.
        :param password: hashable str
        :returns: True when valid, false otherwise
        """

        if not self.password:
            return False
        return bcrypt.verify(password, self.password)
{'fraction_non_alphanumeric': 0.11198288159771755, 'fraction_numerical': 0.011412268188302425, 'mean_word_length': 2.963276836158192, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '796101', 'n_tokens_mistral': 433, 'n_tokens_neox': 410, 'n_words': 121}