2024-12-18 02:20:50 +00:00
|
|
|
from selfprivacy_api.utils.strings import PLEASE_UPDATE_APP_TEXT
|
|
|
|
|
|
|
|
|
2024-10-26 18:22:31 +00:00
|
|
|
class UserNotFound(Exception):
|
2024-12-18 02:20:50 +00:00
|
|
|
"""User not found"""
|
2024-12-05 23:05:28 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def get_error_message() -> str:
|
|
|
|
return "User not found"
|
2024-10-26 18:22:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UserIsProtected(Exception):
|
2024-12-18 02:20:50 +00:00
|
|
|
"""User is protected and cannot be deleted or modified"""
|
2024-12-05 23:05:28 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def get_error_message() -> str:
|
2024-12-11 09:27:58 +00:00
|
|
|
return "User is protected and cannot be deleted or modified"
|
2024-10-26 18:22:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UsernameForbidden(Exception):
|
2024-12-18 02:20:50 +00:00
|
|
|
"""Username is forbidden"""
|
2024-12-05 23:05:28 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def get_error_message() -> str:
|
|
|
|
return "Username is forbidden"
|
2024-10-26 18:22:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UserAlreadyExists(Exception):
|
2024-12-18 02:20:50 +00:00
|
|
|
"""User already exists"""
|
2024-12-05 23:05:28 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def get_error_message() -> str:
|
|
|
|
return "User already exists"
|
2024-10-26 18:22:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UsernameNotAlphanumeric(Exception):
|
2024-12-18 02:20:50 +00:00
|
|
|
"""Username must be alphanumeric and start with a letter"""
|
2024-12-05 23:05:28 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def get_error_message() -> str:
|
2024-12-11 11:16:14 +00:00
|
|
|
return "Username must be alphanumeric and start with a letter"
|
2024-10-26 18:22:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UsernameTooLong(Exception):
|
2024-12-18 02:20:50 +00:00
|
|
|
"""Username is too long. Must be less than 32 characters"""
|
2024-12-05 23:05:28 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def get_error_message() -> str:
|
|
|
|
return "Username is too long. Must be less than 32 characters"
|
2024-10-26 18:22:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
class PasswordIsEmpty(Exception):
|
2024-12-18 02:20:50 +00:00
|
|
|
"""Password cannot be empty"""
|
2024-12-05 23:05:28 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def get_error_message() -> str:
|
|
|
|
return "Password cannot be empty"
|
2024-10-26 18:22:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
class InvalidConfiguration(Exception):
|
2024-12-18 02:20:50 +00:00
|
|
|
"""Invalid configuration, userdata is broken"""
|
2024-12-03 22:54:24 +00:00
|
|
|
|
2024-12-05 23:05:28 +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):
|
2024-12-05 23:05:28 +00:00
|
|
|
"""
|
|
|
|
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."
|
2024-12-11 11:16:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
class DisplaynameTooLong(Exception):
|
2024-12-18 02:20:50 +00:00
|
|
|
"""Display name is too long. Must be less than 16 characters"""
|
2024-12-11 11:16:14 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def get_error_message() -> str:
|
|
|
|
return "Display name is too long. Must be less than 16 characters"
|