Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

models.py 811 B

You have to be logged in to leave a comment. Sign In
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
  1. from datetime import datetime
  2. from src.app import db, login
  3. from flask_login import UserMixin
  4. from werkzeug.security import generate_password_hash, check_password_hash
  5. class User(UserMixin, db.Model):
  6. __tablename__ = "User"
  7. id = db.Column(db.Integer, primary_key=True)
  8. username = db.Column(db.String(64), index=True, unique=True)
  9. email = db.Column(db.String(120), index=True, unique=True)
  10. password_hash = db.Column(db.String(128))
  11. def __repr__(self):
  12. return "<User {}>".format(self.username)
  13. def set_password(self, password):
  14. self.password_hash = generate_password_hash(password)
  15. def check_password(self, password):
  16. return check_password_hash(self.password_hash, password)
  17. @login.user_loader
  18. def load_user(id):
  19. return User.query.get(int(id))
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...