Fix: set pwd can empty

pull/31/head
zijiren233 3 years ago
parent 7d029c8a54
commit 8e63757f2e

@ -99,10 +99,14 @@ func (s *SetRoomPasswordReq) Decode(ctx *gin.Context) error {
}
func (s *SetRoomPasswordReq) Validate() error {
if len(s.Password) > 32 {
return ErrPasswordTooLong
} else if !alnumPrintReg.MatchString(s.Password) {
return ErrPasswordHasInvalidChar
if s.Password != "" {
if len(s.Password) > 32 {
return ErrPasswordTooLong
} else if !alnumPrintReg.MatchString(s.Password) {
return ErrPasswordHasInvalidChar
}
} else if settings.CreateRoomNeedPwd.Get() {
return FormatEmptyPasswordError("room")
}
return nil
}

Loading…
Cancel
Save