From 677e2755b9f5a58ff53c4db670542429ad800176 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 2 Aug 2022 14:36:39 +0530 Subject: [PATCH] Island: Add docstrings to AuthenticationService --- .../cc/services/authentication_service.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/monkey/monkey_island/cc/services/authentication_service.py b/monkey/monkey_island/cc/services/authentication_service.py index 7b32e4f1c..225f57e50 100644 --- a/monkey/monkey_island/cc/services/authentication_service.py +++ b/monkey/monkey_island/cc/services/authentication_service.py @@ -18,6 +18,10 @@ from monkey_island.cc.setup.mongo.database_initializer import reset_database class AuthenticationService: + """ + A service for user authentication + """ + def __init__( self, data_dir: Path, @@ -29,9 +33,21 @@ class AuthenticationService: self._repository_encryptor = repository_encryptor def needs_registration(self) -> bool: + """ + Checks if a user is already registered on the Island + + :return: Whether registration is required on the Island + """ return not self._user_repository.has_registered_users() def register_new_user(self, username: str, password: str): + """ + Registers a new user on the Island, then resets the encryptor and database + + :param username: Username to register + :param password: Password to register + :raises InvalidRegistrationCredentialsError: If username or password is empty + """ if not username or not password: raise InvalidRegistrationCredentialsError("Username or password can not be empty.")