2022-12-08 20:54:47 -05:00
|
|
|
"""
|
|
|
|
User performs user related crud operations
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
|
|
Copyright © 2022 Concordia CERC group
|
|
|
|
Project CoderPeter Yefi peteryefi@gmail.com
|
|
|
|
"""
|
2023-02-22 22:45:33 -05:00
|
|
|
from hub.persistence import User
|
2022-12-08 20:54:47 -05:00
|
|
|
|
|
|
|
|
|
|
|
class UserFactory:
|
|
|
|
"""
|
|
|
|
UserFactory class
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, db_name, app_env, dotenv_path):
|
2023-02-22 22:45:33 -05:00
|
|
|
self._user_repo = User(db_name=db_name, app_env=app_env, dotenv_path=dotenv_path)
|
2022-12-08 20:54:47 -05:00
|
|
|
|
2023-02-22 22:45:33 -05:00
|
|
|
def login_user(self, name: str, password: str, application_id: int):
|
2022-12-08 20:54:47 -05:00
|
|
|
"""
|
|
|
|
Retrieve a single city from postgres
|
2023-02-22 22:45:33 -05:00
|
|
|
:param name: the email of the user
|
2022-12-08 20:54:47 -05:00
|
|
|
:param password: the password of the user
|
2023-02-22 22:45:33 -05:00
|
|
|
:param application_id: the id of the application accessing hub
|
2022-12-08 20:54:47 -05:00
|
|
|
"""
|
2023-02-22 22:45:33 -05:00
|
|
|
return self._user_repo.get_by_name_application_and_password(name, password, application_id)
|
2022-12-08 20:54:47 -05:00
|
|
|
|
2023-02-22 22:45:33 -05:00
|
|
|
def get_by_name_and_application(self, name: str, application: int):
|
2022-12-08 20:54:47 -05:00
|
|
|
"""
|
|
|
|
Retrieve a single user
|
2023-02-22 22:45:33 -05:00
|
|
|
:param name: user name
|
|
|
|
:param application: application accessing hub
|
2022-12-08 20:54:47 -05:00
|
|
|
"""
|
2023-02-22 22:45:33 -05:00
|
|
|
return self._user_repo.get_by_name_and_application(name, application)
|