diff --git a/api/src/main/java/run/halo/app/core/user/service/SignUpData.java b/api/src/main/java/run/halo/app/core/user/service/SignUpData.java index e3d07a99fb..7fab3d4ccc 100644 --- a/api/src/main/java/run/halo/app/core/user/service/SignUpData.java +++ b/api/src/main/java/run/halo/app/core/user/service/SignUpData.java @@ -13,10 +13,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.util.Objects; -import java.util.Optional; import lombok.Data; -import org.springframework.util.MultiValueMap; -import org.springframework.util.StringUtils; import run.halo.app.infra.ValidationUtils; /** @@ -52,35 +49,6 @@ public class SignUpData { @NotBlank private String confirmPassword; - public static SignUpData of(MultiValueMap formData) { - var form = new SignUpData(); - Optional.ofNullable(formData.getFirst("username")) - .filter(StringUtils::hasText) - .ifPresent(form::setUsername); - - Optional.ofNullable(formData.getFirst("displayName")) - .filter(StringUtils::hasText) - .ifPresent(form::setDisplayName); - - Optional.ofNullable(formData.getFirst("email")) - .filter(StringUtils::hasText) - .ifPresent(form::setEmail); - - Optional.ofNullable(formData.getFirst("password")) - .filter(StringUtils::hasText) - .ifPresent(form::setPassword); - - Optional.ofNullable(formData.getFirst("emailCode")) - .filter(StringUtils::hasText) - .ifPresent(form::setEmailCode); - - Optional.ofNullable(formData.getFirst("confirmPassword")) - .filter(StringUtils::hasText) - .ifPresent(form::setConfirmPassword); - - return form; - } - @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Constraint(validatedBy = {SignUpDataConstraintValidator.class}) diff --git a/application/src/main/java/run/halo/app/security/preauth/PreAuthSignUpEndpoint.java b/application/src/main/java/run/halo/app/security/preauth/PreAuthSignUpEndpoint.java index b653250b29..57595adc84 100644 --- a/application/src/main/java/run/halo/app/security/preauth/PreAuthSignUpEndpoint.java +++ b/application/src/main/java/run/halo/app/security/preauth/PreAuthSignUpEndpoint.java @@ -79,8 +79,7 @@ RouterFunction preAuthSignUpEndpoints() { .POST( "", contentType(APPLICATION_FORM_URLENCODED), - request -> request.formData() - .map(SignUpData::of) + request -> request.bind(SignUpData.class) .flatMap(signUpData -> { // sign up var bindingResult = validate(signUpData, validator, request.exchange());