| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- from .user import user
- from .user import user_factory
- from .user import user_builder
- from .users_collection import users_collection
- from .app_route import app_route
- class users_app(app_route):
- def __init__(self, collection: users_collection) -> None:
- self.__collection = collection
- def login(self, sended: dict) -> dict:
- self._require(sended, "nick", "password")
-
- nick = sended["nick"]
- password = sended["password"]
- target = self.collection.login(nick, password)
- if target is None:
- return self._fail("Bad nick or password.")
- return self._success(apikey = target.apikey)
- def get(self, sended: dict) -> dict:
- self._require(sended, "apikey")
- apikey = sended["apikey"]
- target = self.collection.get(apikey)
- if target is None:
- return self._fail("User with that ApiKey not exists.")
- return self._success(
- apikey = target.apikey,
- nick = target.nick
- )
- @property
- def collection(self) -> users_collection:
- return self.__collection
|