-
-
Save altendky/cfd9d3086eea753d12bed2a2c83bede7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class IdModel: | |
id = db.Column(db.Integer, primary_key=True) | |
class User(IdModel, UserMixin, db.Model): | |
username = db.Column(db.String(64), index=True, unique=True) | |
email = db.Column(db.String(128), index=True, unique=True) | |
password_hash = db.Column(db.String(128)) | |
def __repr__(self): | |
return '<User {}>'.format(self.username) | |
def set_password(self, password): | |
self.password_hash = generate_password_hash(password) | |
def check_password(self, password): | |
return check_password_hash(self.password_hash, password) | |
@classmethod | |
@login.user_loader | |
def load_user(cls, id_): | |
return cls.query.get(int(id_)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment