Skip to content

Commit

Permalink
Login Schema now in use.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewhand committed Sep 11, 2023
1 parent 4ec1dc5 commit c610542
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/dioptra/restapi/auth/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
9 changes: 3 additions & 6 deletions src/dioptra/restapi/auth/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions src/dioptra/restapi/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit c610542

Please sign in to comment.