Fix: signup with email need password

pull/119/head
zijiren233 11 months ago
parent 202d4b583c
commit d42281115f

@ -437,9 +437,9 @@ func UserSignupEmail(ctx *gin.Context) {
var user *op.UserEntry
if settings.SignupNeedReview.Get() || email.SignupNeedReview.Get() {
user, err = op.CreateUserWithEmail(req.Email, utils.RandString(16), req.Email, db.WithRole(dbModel.RolePending))
user, err = op.CreateUserWithEmail(req.Email, req.Password, req.Email, db.WithRole(dbModel.RolePending))
} else {
user, err = op.CreateUserWithEmail(req.Email, utils.RandString(16), req.Email)
user, err = op.CreateUserWithEmail(req.Email, req.Password, req.Email)
}
if err != nil {
log.Errorf("failed to create user: %v", err)

@ -172,7 +172,28 @@ func (u *UserBindEmailReq) Validate() error {
type SendUserSignupEmailCaptchaReq = UserSendBindEmailCaptchaReq
type UserSignupEmailReq = UserBindEmailReq
type UserSignupEmailReq struct {
UserBindEmailReq
Password string `json:"password"`
}
func (u *UserSignupEmailReq) Decode(ctx *gin.Context) error {
return json.NewDecoder(ctx.Request.Body).Decode(u)
}
func (u *UserSignupEmailReq) Validate() error {
if err := u.UserBindEmailReq.Validate(); err != nil {
return err
}
if u.Password == "" {
return FormatEmptyPasswordError("user")
} else if len(u.Password) > 32 {
return ErrPasswordTooLong
} else if !alnumPrintReg.MatchString(u.Password) {
return ErrPasswordHasInvalidChar
}
return nil
}
type SendUserRetrievePasswordEmailCaptchaReq = UserSendBindEmailCaptchaReq

Loading…
Cancel
Save