diff --git a/monkey/monkey_island/cc/environment/environment_config.py b/monkey/monkey_island/cc/environment/environment_config.py index 70d27e546..183d10932 100644 --- a/monkey/monkey_island/cc/environment/environment_config.py +++ b/monkey/monkey_island/cc/environment/environment_config.py @@ -38,7 +38,7 @@ class EnvironmentConfig: self._load_from_dict(data) def _load_from_dict(self, dict_data: Dict): - user_creds = UserCreds.get_from_dict(dict_data) + user_creds = UserCreds.get_from_dict_server_config(dict_data) aws = dict_data["aws"] if "aws" in dict_data else None data_dir = dict_data["data_dir"] if "data_dir" in dict_data else DEFAULT_DATA_DIR diff --git a/monkey/monkey_island/cc/environment/user_creds.py b/monkey/monkey_island/cc/environment/user_creds.py index 1574f6e8e..385083311 100644 --- a/monkey/monkey_island/cc/environment/user_creds.py +++ b/monkey/monkey_island/cc/environment/user_creds.py @@ -28,7 +28,7 @@ class UserCreds: return User(1, self.username, self.password_hash) @staticmethod - def get_from_dict(data_dict: Dict) -> UserCreds: + def get_from_dict_new_registration(data_dict: Dict) -> UserCreds: creds = UserCreds() if "user" in data_dict: creds.username = data_dict["user"] @@ -38,7 +38,16 @@ class UserCreds: ).decode() return creds + @staticmethod + def get_from_dict_server_config(data_dict: Dict) -> UserCreds: + creds = UserCreds() + if "user" in data_dict: + creds.username = data_dict["user"] + if "password_hash" in data_dict: + creds.password_hash = data_dict["password_hash"] + return creds + @staticmethod def get_from_json(json_data: bytes) -> UserCreds: cred_dict = json.loads(json_data) - return UserCreds.get_from_dict(cred_dict) + return UserCreds.get_from_dict_new_registration(cred_dict)