From c6105420d5fcdbdc95f5ce69d6112ea4406138eb Mon Sep 17 00:00:00 2001 From: Andrew Hand Date: Mon, 11 Sep 2023 14:44:07 -0400 Subject: [PATCH] Login Schema now in use. --- src/dioptra/restapi/auth/controller.py | 3 +-- src/dioptra/restapi/auth/service.py | 9 +++------ src/dioptra/restapi/errors.py | 2 ++ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/dioptra/restapi/auth/controller.py b/src/dioptra/restapi/auth/controller.py index 01a67bf0a..89302985e 100644 --- a/src/dioptra/restapi/auth/controller.py +++ b/src/dioptra/restapi/auth/controller.py @@ -56,8 +56,7 @@ def post(self) -> Response: log: BoundLogger = LOGGER.new( request_id=str(uuid.uuid4()), resource="auth", request_type="POST" ) - return self._auth_service.login(data=request.parsed_obj, log=log) - # return self._auth_service.login(login_data=request.parsed_obj, log=log) + return self._auth_service.login(login_data=request.parsed_obj, log=log) @api.route("/logout") class LogoutResource(Resource): diff --git a/src/dioptra/restapi/auth/service.py b/src/dioptra/restapi/auth/service.py index 7f9fcc714..d521facfd 100644 --- a/src/dioptra/restapi/auth/service.py +++ b/src/dioptra/restapi/auth/service.py @@ -44,16 +44,13 @@ def __init__( def login( self, - data: dict[str, Any], - # login_data: LoginData, + login_data: LoginData, **kwargs, ) -> Response: # ) -> Response | tuple[Response, int]: log: BoundLogger = kwargs.get("log", LOGGER.new()) - username = data.get("username", "guest") - password = data.get("password", "") - # username = login_data.get("username", "guest") - # password = login_data.get("password", "") + username = login_data.get("username", "guest") + password = login_data.get("password", "") user = self._user_service.authenticate_user(name=username, password=password) if not user: diff --git a/src/dioptra/restapi/errors.py b/src/dioptra/restapi/errors.py index 1daabf9d2..215b48708 100644 --- a/src/dioptra/restapi/errors.py +++ b/src/dioptra/restapi/errors.py @@ -29,6 +29,7 @@ def register_error_handlers(api: Api) -> None: Args: api: The main REST |Api| object. """ + from .auth import register_error_handlers as attach_auth_error_handlers from .experiment import register_error_handlers as attach_experiment_error_handlers from .job import register_error_handlers as attach_job_error_handlers from .queue import register_error_handlers as attach_job_queue_error_handlers @@ -38,6 +39,7 @@ def register_error_handlers(api: Api) -> None: from .user import register_error_handlers as attach_user_error_handlers # Add error handlers + attach_auth_error_handlers(api) attach_experiment_error_handlers(api) attach_job_error_handlers(api) attach_job_queue_error_handlers(api)