webcodelab commited on
Commit
dbc1a11
·
verified ·
1 Parent(s): 431b73c

Update app/models.py

Browse files
Files changed (1) hide show
  1. app/models.py +23 -23
app/models.py CHANGED
@@ -1,30 +1,30 @@
1
- from . import db
2
- from werkzeug.security import generate_password_hash, check_password_hash
3
- import uuid
4
- import secrets
5
 
6
- class User(db.Model):
7
- id = db.Column(db.Integer, primary_key=True)
8
- username = db.Column(db.String(150), unique=True, nullable=False)
9
- email = db.Column(db.String(150), unique=True, nullable=False)
10
- password_hash = db.Column(db.String(256), nullable=False)
11
 
12
- is_verified = db.Column(db.Boolean, default=False)
13
- verification_token = db.Column(db.String(64), unique=True, nullable=True, default=lambda: str(uuid.uuid4()))
14
 
15
- api_key = db.Column(db.String(64), unique=True, nullable=True, default=lambda: secrets.token_hex(32))
16
 
17
- def generate_api_key(self):
18
- raw_key = secrets.token_hex(32)
19
- self.api_key = f"amn={raw_key}"
20
- db.session.commit()
21
 
22
- def generate_verification_token(self):
23
- self.verification_token = str(uuid.uuid4())
24
- db.session.commit()
25
 
26
- def set_password(self, password):
27
- self.password_hash = generate_password_hash(password)
28
 
29
- def check_password(self, password):
30
- return check_password_hash(self.password_hash, password)
 
1
+ # from . import db
2
+ # from werkzeug.security import generate_password_hash, check_password_hash
3
+ # import uuid
4
+ # import secrets
5
 
6
+ # class User(db.Model):
7
+ # id = db.Column(db.Integer, primary_key=True)
8
+ # username = db.Column(db.String(150), unique=True, nullable=False)
9
+ # email = db.Column(db.String(150), unique=True, nullable=False)
10
+ # password_hash = db.Column(db.String(256), nullable=False)
11
 
12
+ # is_verified = db.Column(db.Boolean, default=False)
13
+ # verification_token = db.Column(db.String(64), unique=True, nullable=True, default=lambda: str(uuid.uuid4()))
14
 
15
+ # api_key = db.Column(db.String(64), unique=True, nullable=True, default=lambda: secrets.token_hex(32))
16
 
17
+ # def generate_api_key(self):
18
+ # raw_key = secrets.token_hex(32)
19
+ # self.api_key = f"amn={raw_key}"
20
+ # db.session.commit()
21
 
22
+ # def generate_verification_token(self):
23
+ # self.verification_token = str(uuid.uuid4())
24
+ # db.session.commit()
25
 
26
+ # def set_password(self, password):
27
+ # self.password_hash = generate_password_hash(password)
28
 
29
+ # def check_password(self, password):
30
+ # return check_password_hash(self.password_hash, password)