xygt/app/models.py

23 lines
753 B
Python
Raw Normal View History

from flask_login import UserMixin
from config import Config
class User(UserMixin):
def __init__(self, user, userid, password, idpass, level):
self.user = user
self.password = password
self.userid = userid
self.idpass = idpass
self.level = level
def __repr__(self):
return f"User('{self.user}', '{self.userid}', '{self.password}', '{self.idpass}', '{self.level}')"
2023-12-26 21:13:07 +01:00
def get_id(self):
return str(self.userid)
2023-12-26 21:13:07 +01:00
def get(self):
userData = Config.users.find_one({"userid": self})
if not userData:
return None
else:
return User(userData["user"], userData["userid"], userData["password"], userData["idpass"], userData["level"])