Created
September 23, 2018 19:37
-
-
Save piyonishi/1b1b6475df66fef200075ddd518d90ab to your computer and use it in GitHub Desktop.
This file contains hidden or 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 User(db.Model): | |
__tablename__ = 'users' | |
id = db.Column(db.Integer, primary_key=True) | |
name = db.Column(db.String(80), unique=True, index = True) | |
email = db.Column(db.String(120), unique=True, index = True) | |
image_url = db.Column(db.String(120), unique=True, index =True) | |
def __init__(self, name, password, email, image_url): | |
self.name = name | |
self.set_password(password) | |
self.email = email | |
self.image_url = image_url | |
def set_password(self, password): | |
self.pw_hash = generate_password_hash(password) | |
def check_password(self, password): | |
return check_password_hash(self.pw_hash, password) | |
def __repr__(self): | |
return '<User %r>' % self.name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment