-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodel.py
25 lines (19 loc) · 812 Bytes
/
model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from flask_sqlalchemy import SQLAlchemy
from werkzeug import generate_password_hash, check_password_hash
db = SQLAlchemy()
class User(db.Model):
_tablename_ = "users"
uid = db.Column(db.Integer,primary_key = True)
firstname = db.Column(db.String(100))
lasttname = db.Column(db.String(100))
email = db.Column(db.String(120),unique = True)
pwdhash = db.Column(db.String(54))
def _init_(self,firstname,lastname,email,password):
self.firstname = firstname.title()
self.lasttname = lastname.title()
self.email = email.lower()
self.set_password(password)
def set_password(self,password):
self.pwdhash = generate_password_hash(password)
def check_password(self,password):
return check_password_hash(self.pwdhash,password)