Add auth levels and logging

This commit is contained in:
april
2023-12-19 10:58:07 -06:00
parent c0a33397fc
commit 3ec92573e1
2 changed files with 112 additions and 22 deletions

View File

@@ -8,11 +8,29 @@ class AuthLevel(Enum):
USER = 1
ADMIN = 2
def __lt__(self, other):
if self.__class__ is other.__class__:
return self.value < other.value
return NotImplemented
def __gt__(self, other):
if self.__class__ is other.__class__:
return self.value > other.value
return NotImplemented
def __eq__(self, other):
if self.__class__ is other.__class__:
return self.value == other.value
return NotImplemented
class User(Document):
username = StringField(required=True, unique=True)
password = StringField(required=True)
level = EnumField(AuthLevel, default=AuthLevel.USER)
# EnumField validation is currently broken, replace workaround if MongoEngine is updated to fix it
level = IntField(choices=[l.value for l in AuthLevel], default=1)
# level = EnumField(AuthLevel, default=AuthLevel.USER)
class Flight(Document):