diff --git a/monkey/monkey_island/cc/resources/auth/registration.py b/monkey/monkey_island/cc/resources/auth/registration.py index 75cef5018..fd9532456 100644 --- a/monkey/monkey_island/cc/resources/auth/registration.py +++ b/monkey/monkey_island/cc/resources/auth/registration.py @@ -3,7 +3,6 @@ import logging import flask_restful from flask import make_response, request -import monkey_island.cc.environment.environment_singleton as env_singleton from common.utils.exceptions import InvalidRegistrationCredentialsError, RegistrationNotNeededError from monkey_island.cc.resources.auth.credential_utils import get_username_password_from_request from monkey_island.cc.services.authentication import AuthenticationService @@ -13,8 +12,7 @@ logger = logging.getLogger(__name__) class Registration(flask_restful.Resource): def get(self): - is_registration_needed = env_singleton.env.needs_registration() - return {"needs_registration": is_registration_needed} + return {"needs_registration": AuthenticationService.needs_registration()} def post(self): username, password = get_username_password_from_request(request) diff --git a/monkey/monkey_island/cc/services/authentication.py b/monkey/monkey_island/cc/services/authentication.py index 517b3a50b..fe3542f51 100644 --- a/monkey/monkey_island/cc/services/authentication.py +++ b/monkey/monkey_island/cc/services/authentication.py @@ -19,6 +19,10 @@ class AuthenticationService: def initialize(cls, key_file_directory): cls.KEY_FILE_DIRECTORY = key_file_directory + @classmethod + def needs_registration(cls) -> bool: + return env_singleton.env.needs_registration() + @classmethod def register_new_user(cls, username: str, password: str): credentials = UserCreds(username, _hash_password(password))