2025-03-29 20:57:01 +00:00

21 lines
733 B
Python

from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class User(db.Model):
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
username = db.Column(db.String(20), unique=True, nullable=False)
email = db.Column(db.String(120), unique=True, nullable=False)
role = db.Column(db.Enum('Administrator', 'User'), default='User')
password = db.Column(db.String(162), nullable=False)
def to_dict(self):
return {"id": self.id, "username": self.username, "email": self.email, "role": self.role}
@staticmethod
def get_editable_fields():
return {"username", "email", "role", "password"}
class RevokedToken(db.Model):
jti = db.Column(db.String(100), primary_key=True)