<commit_before>from app import db
from sqlalchemy.sql.expression import select, exists

class Auth(db.Model):
    __tablename__ = 'users'

    id       = db.Column(db.Integer, primary_key= True)
    username = db.Column(db.String, unique=True)
    password = db.Column(db.String)

    def __init__(self, username=None, password=None):
        self.username = username
        self.password = password

    def __repr__(self):
        return '<User %r>' % (self.username)

    def exists(self):
        return db.session.query(exists().where(Auth.username == self.username)).scalar()<commit_msg>Added password hashing<commit_after>from app import db, passwords
from sqlalchemy.sql.expression import select, exists
# from passwords import hash_password, check_password 

class Auth(db.Model):
    __tablename__ = 'users'

    id       = db.Column(db.Integer, primary_key= True)
    username = db.Column(db.String, unique=True)
    password = db.Column(db.String)

    def __init__(self, username, password=None):
        self.username = username

        if password:
            self.password = passwords.hash_password(password)

    def __repr__(self):
        return '<User %r>' % (self.username)

    def set_password(self, password):
        """Generate a random salt and return a new hash for the password."""
        self.password = passwords.hash_password(password)


    def check_password(self, password):
        """Check a password against an existing hash."""
        return passwords.check_password(self.password, password)
{'fraction_non_alphanumeric': 0.10879478827361563, 'fraction_numerical': 0.0, 'mean_word_length': 3.3146067415730336, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3043121', 'n_tokens_mistral': 445, 'n_tokens_neox': 425, 'n_words': 116}