mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-25 17:22:55 +00:00
chore: add SEND_EMAIL_ERROR exception code for email-related validations
This commit is contained in:
parent
6d5664c674
commit
903ad0ecf6
|
|
@ -42,3 +42,4 @@ class ExceptionCodeConstants(Enum):
|
|||
PASSWORD_NOT_EQ_RE_PASSWORD = ExceptionCodeConstantsValue(1007,
|
||||
_('Password and confirmation password are inconsistent'))
|
||||
NICKNAME_IS_EXIST = ExceptionCodeConstantsValue(1008, _('The nickname is already registered'))
|
||||
SEND_EMAIL_ERROR = ExceptionCodeConstantsValue(1009, _("Email sending failed"))
|
||||
|
|
|
|||
|
|
@ -1047,9 +1047,9 @@ class SendEmailSerializer(serializers.Serializer):
|
|||
super().is_valid(raise_exception=raise_exception)
|
||||
user_exists = QuerySet(User).filter(email=self.data.get('email')).exists()
|
||||
if not user_exists and self.data.get('type') == 'reset_password':
|
||||
raise ExceptionCodeConstants.EMAIL_IS_NOT_EXIST.value.to_app_api_exception()
|
||||
raise ExceptionCodeConstants.SEND_EMAIL_ERROR.value.to_app_api_exception()
|
||||
elif user_exists and self.data.get('type') == 'register':
|
||||
raise ExceptionCodeConstants.EMAIL_IS_EXIST.value.to_app_api_exception()
|
||||
raise ExceptionCodeConstants.SEND_EMAIL_ERROR.value.to_app_api_exception()
|
||||
code_cache_key = self.data.get('email') + ":" + self.data.get("type")
|
||||
code_cache_key_lock = code_cache_key + "_lock"
|
||||
ttl = cache.ttl(code_cache_key_lock, version=version)
|
||||
|
|
|
|||
Loading…
Reference in New Issue