-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodel
More file actions
75 lines (55 loc) · 2.31 KB
/
model
File metadata and controls
75 lines (55 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from paymiummApp_server import db, login_manager
from werkzeug.security import generate_password_hash, check_password_hash
from flask_login import UserMixin
class User(UserMixin, db.Model):
"""UserMixin, This provides default implementations for the methods that Flask-Login
expects user objects to have."""
__tablename__ = 'User'
id = db.Column(db.Integer, primary_key=True)
full_name = db.Column(db.String(60))
username = db.Column(db.String(120), unique=True)
email = db.Column(db.String(120), unique=True)
phone_number = db.Column(db.String(15))
password_hash = db.Column(db.String(100))
email_confirmed = db.Column(db.Boolean, default=False)
account_confirmed = db.Column(db.Boolean, default=False)
img_path = db.Column(db.String(100))
dev_identity = db.Column(db.String(100))
# user = db.relationship('PrivateDetails', backref='users', lazy='dynamic')
def is_active(self):
"""True, as all users are active."""
return True
def get_id(self):
"""Return the email address to satisfy Flask-Login's requirements."""
return self.id
def is_authenticated(self):
"""Return True if the user is authenticated."""
return self.email_confirmed
def is_anonymous(self):
"""False, as anonymous users aren't supported."""
return False
@property
def password(self):
raise AttributeError('password is not in readable format')
@password.setter
def password(self, plaintext):
self.password_hash = generate_password_hash(plaintext)
def verify_password(self, plaintext):
if check_password_hash(self.password_hash, plaintext):
return True
return False
def __repr__(self):
"""This method is used for debugging"""
return 'User {}'.format(self.username)
class PrivateDetails(db.Model):
__tablename__ = 'PrivateDetails'
id = db.Column(db.Integer, primary_key=True)
address = db.Column(db.String(200))
city = db.Column(db.String(160))
state = db.Column(db.String(100))
postal_code = db.Column(db.String(50))
date_of_birth = db.Column(db.String(20))
user_id = db.Column(db.String(255))
# users_id = db.Column(db.Integer, db.ForeignKey('User.id'))
def __repr__(self):
return 'User {}'.format(self.address)