flaschengeist/geruecht/model/user.py

26 lines
832 B
Python
Raw Normal View History

2019-04-11 21:56:55 +00:00
from geruecht import db
from geruecht import bcrypt
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
userID = db.Column(db.String, nullable=False, unique=True)
username = db.Column(db.String, nullable=False, unique=True)
firstname = db.Column(db.String, nullable=False)
lastname = db.Column(db.String, nullable=False)
group = db.Column(db.String, nullable=False)
password = db.Column(db.String, nullable=False)
def toJSON(self):
dic = {
"userId": self.userID,
2019-04-11 21:56:55 +00:00
"username": self.username,
"firstname": self.firstname,
"lastname": self.lastname,
"group": self.group,
}
return dic
def login(self, password):
return True if bcrypt.check_password_hash(self.password, password) else False