mirror of
				https://github.com/StefBuwalda/ProjectIOT.git
				synced 2025-10-30 19:29:57 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			20 lines
		
	
	
		
			707 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			20 lines
		
	
	
		
			707 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| from application import db
 | |
| from flask_login import UserMixin
 | |
| from werkzeug.security import generate_password_hash, check_password_hash
 | |
| 
 | |
| 
 | |
| # User model
 | |
| class User(db.Model, UserMixin):
 | |
|     __tablename__ = "user"
 | |
|     id = db.Column(db.Integer, primary_key=True)
 | |
|     username = db.Column(db.String(150), unique=True, nullable=False)
 | |
|     password = db.Column(db.String, nullable=False)
 | |
| 
 | |
|     # Initialize user, prevents red stuff
 | |
|     def __init__(self, username: str, password: str, is_admin: bool = False):
 | |
|         self.username = username
 | |
|         self.password = generate_password_hash(password)
 | |
| 
 | |
|     def check_password(self, password: str):
 | |
|         return check_password_hash(self.password, password=password)
 |