2023-12-26 20:16:58 +01:00
|
|
|
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
|
|
|
|
2023-12-26 20:16:58 +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})
|
2023-12-26 20:16:58 +01:00
|
|
|
if not userData:
|
|
|
|
return None
|
|
|
|
else:
|
|
|
|
return User(userData["user"], userData["userid"], userData["password"], userData["idpass"], userData["level"])
|