Last active
December 22, 2017 17:56
-
-
Save RyanBreaker/14a0730e62010d21f050f617698e3c31 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) | |
@staticmethod | |
@login.user_loader | |
def load_user(id_): | |
return User.query.get(int(id_)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment