mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-20 02:51:27 +00:00
feat: 忘记密码支持手机短信找回,并修改邮箱方式和手机方式统一 (#8960)
* feat: 忘记密码支持通过手机找回,邮箱方式修改为和手机方式一致 * feat: 翻译 * feat: 修改翻译 * fix: 还原 Co-authored-by: Jiangjie.Bai <bugatti_it@163.com>
This commit is contained in:
@@ -1,15 +1,41 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from rest_framework import serializers
|
||||
|
||||
from common.drf.fields import EncryptedField
|
||||
|
||||
__all__ = [
|
||||
'MFAChallengeSerializer', 'MFASelectTypeSerializer',
|
||||
'PasswordVerifySerializer',
|
||||
'PasswordVerifySerializer', 'ResetPasswordCodeSerializer',
|
||||
]
|
||||
|
||||
|
||||
class ResetPasswordCodeSerializer(serializers.Serializer):
|
||||
form_type = serializers.CharField(default='email')
|
||||
username = serializers.CharField()
|
||||
email = serializers.CharField(allow_blank=True)
|
||||
phone = serializers.CharField(allow_blank=True)
|
||||
|
||||
def create(self, attrs):
|
||||
error = []
|
||||
form_type = attrs.get('form_type', 'email')
|
||||
username = attrs.get('username')
|
||||
if not username:
|
||||
error.append(_('The {} cannot be empty').format(_('Username')))
|
||||
if form_type == 'phone':
|
||||
phone = attrs.get('phone')
|
||||
if not phone:
|
||||
error.append(_('The {} cannot be empty').format(_('Phone')))
|
||||
else:
|
||||
email = attrs.get('email')
|
||||
if not email:
|
||||
error.append(_('The {} cannot be empty').format(_('Email')))
|
||||
|
||||
if error:
|
||||
raise serializers.ValidationError(error)
|
||||
|
||||
|
||||
class PasswordVerifySerializer(serializers.Serializer):
|
||||
password = EncryptedField()
|
||||
|
||||
|
Reference in New Issue
Block a user