flaschengeist/geruecht/model/user.py

26 lines
832 B
Python

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,
"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