@@ -512,14 +512,6 @@ def update_user_role(instance, user):
512512
513513
514514class RePasswordSerializer (serializers .Serializer ):
515- email = serializers .EmailField (
516- required = True ,
517- label = _ ("Email" ),
518- validators = [validators .EmailValidator (message = ExceptionCodeConstants .EMAIL_FORMAT_ERROR .value .message ,
519- code = ExceptionCodeConstants .EMAIL_FORMAT_ERROR .value .code )])
520-
521- code = serializers .CharField (required = True , label = _ ("Verification code" ))
522-
523515 password = serializers .CharField (required = True , label = _ ("Password" ),
524516 validators = [validators .RegexValidator (regex = re .compile (
525517 "^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z_!@#$%^&*`~.()-+=]+$)(?![a-z0-9]+$)(?![a-z_!@#$%^&*`~()-+=]+$)"
@@ -541,28 +533,19 @@ class Meta:
541533
542534 def is_valid (self , * , raise_exception = False ):
543535 super ().is_valid (raise_exception = True )
544- email = self .data .get ("email" )
545- cache_code = cache .get (get_key (email + ':reset_password' ), version = version )
546536 if self .data .get ('password' ) != self .data .get ('re_password' ):
547537 raise AppApiException (ExceptionCodeConstants .PASSWORD_NOT_EQ_RE_PASSWORD .value .code ,
548538 ExceptionCodeConstants .PASSWORD_NOT_EQ_RE_PASSWORD .value .message )
549- if cache_code != self .data .get ('code' ):
550- raise AppApiException (ExceptionCodeConstants .CODE_ERROR .value .code ,
551- ExceptionCodeConstants .CODE_ERROR .value .message )
552539 return True
553540
554- def reset_password (self ):
541+ def reset_password (self , user_id : str ):
555542 """
556543 修改密码
557544 :return: 是否成功
558545 """
559546 if self .is_valid ():
560- email = self .data .get ("email" )
561- QuerySet (User ).filter (email = email ).update (
547+ QuerySet (User ).filter (id = user_id ).update (
562548 password = password_encrypt (self .data .get ('password' )))
563- code_cache_key = email + ":reset_password"
564- # 删除验证码缓存
565- cache .delete (code_cache_key , version = version )
566549 return True
567550
568551
0 commit comments