From 6f2a750a13c724f1e1bc6f1d992b170c4a444196 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Tue, 12 Jul 2022 09:55:11 -0400 Subject: [PATCH] Island: Use HTTPStatus Enum in Authenticate resource --- monkey/monkey_island/cc/resources/auth/auth.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/monkey/monkey_island/cc/resources/auth/auth.py b/monkey/monkey_island/cc/resources/auth/auth.py index 69aa1ffcd..34632bf7e 100644 --- a/monkey/monkey_island/cc/resources/auth/auth.py +++ b/monkey/monkey_island/cc/resources/auth/auth.py @@ -1,4 +1,5 @@ import logging +from http import HTTPStatus import flask_jwt_extended from flask import make_response, request @@ -47,7 +48,7 @@ class Authenticate(AbstractResource): self._authentication_service.authenticate(username, password) access_token = create_access_token(username) except IncorrectCredentialsError: - return make_response({"error": "Invalid credentials"}, 401) + return make_response({"error": "Invalid credentials"}, HTTPStatus.UNAUTHORIZED) # API Spec: Why are we sending "error" here? - return make_response({"access_token": access_token, "error": ""}, 200) + return make_response({"access_token": access_token, "error": ""}, HTTPStatus.OK)