Skip to content

Instantly share code, notes, and snippets.

@RyanBreaker
Last active December 22, 2017 17:56
Show Gist options
  • Save RyanBreaker/14a0730e62010d21f050f617698e3c31 to your computer and use it in GitHub Desktop.
Save RyanBreaker/14a0730e62010d21f050f617698e3c31 to your computer and use it in GitHub Desktop.
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