forked from p15670423/monkey
Island: Add docstrings to AuthenticationService
This commit is contained in:
parent
4801235c4b
commit
677e2755b9
|
@ -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.")
|
||||
|
||||
|
|
Loading…
Reference in New Issue