selfprivacy-rest-api/selfprivacy_api/repositories/users/exceptions.py

92 lines
2.3 KiB
Python
Raw Normal View History

2024-12-18 02:20:50 +00:00
from selfprivacy_api.utils.strings import PLEASE_UPDATE_APP_TEXT
class UserNotFound(Exception):
2024-12-18 02:20:50 +00:00
"""User not found"""
@staticmethod
def get_error_message() -> str:
return "User not found"
class UserIsProtected(Exception):
2024-12-18 02:20:50 +00:00
"""User is protected and cannot be deleted or modified"""
@staticmethod
def get_error_message() -> str:
return "User is protected and cannot be deleted or modified"
class UsernameForbidden(Exception):
2024-12-18 02:20:50 +00:00
"""Username is forbidden"""
@staticmethod
def get_error_message() -> str:
return "Username is forbidden"
class UserAlreadyExists(Exception):
2024-12-18 02:20:50 +00:00
"""User already exists"""
@staticmethod
def get_error_message() -> str:
return "User already exists"
class UsernameNotAlphanumeric(Exception):
2024-12-18 02:20:50 +00:00
"""Username must be alphanumeric and start with a letter"""
@staticmethod
def get_error_message() -> str:
return "Username must be alphanumeric and start with a letter"
class UsernameTooLong(Exception):
2024-12-18 02:20:50 +00:00
"""Username is too long. Must be less than 32 characters"""
@staticmethod
def get_error_message() -> str:
return "Username is too long. Must be less than 32 characters"
class PasswordIsEmpty(Exception):
2024-12-18 02:20:50 +00:00
"""Password cannot be empty"""
@staticmethod
def get_error_message() -> str:
return "Password cannot be empty"
class InvalidConfiguration(Exception):
2024-12-18 02:20:50 +00:00
"""Invalid configuration, userdata is broken"""
2024-12-03 22:54:24 +00:00
@staticmethod
def get_error_message() -> str:
return "Invalid configuration, userdata is broken"
2024-12-03 22:54:24 +00:00
class SelfPrivacyAppIsOutdate(Exception):
"""
SelfPrivacy app is out of date, please update. Some important functions are not working at the moment.
"""
@staticmethod
def get_error_message() -> str:
2024-12-18 02:20:50 +00:00
return PLEASE_UPDATE_APP_TEXT
2024-12-09 08:37:57 +00:00
class NoPasswordResetLinkFoundInResponse(Exception):
"""No password reset link was found in the Kanidm response."""
@staticmethod
def get_error_message() -> str:
return "The Kanidm response does not contain a password reset link."
class DisplaynameTooLong(Exception):
2024-12-18 02:20:50 +00:00
"""Display name is too long. Must be less than 16 characters"""
@staticmethod
def get_error_message() -> str:
return "Display name is too long. Must be less than 16 characters"