From ce449e3101ac53d07219bc27cebb5c52371e2664 Mon Sep 17 00:00:00 2001 From: AlexBob <5199840@qq.com> Date: Thu, 30 May 2024 14:50:43 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E6=9B=B4=E6=96=B0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=9C=8D=E5=8A=A1=E4=BB=A5=E5=A4=84=E7=90=86=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E5=8A=A0=E5=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/platform/boot/security/core/user/UsersRepository.java | 2 +- .../com/platform/boot/security/core/user/UsersService.java | 3 +-- .../java/com/platform/boot/security/filter/CaptchaFilter.java | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/boot/platform/src/main/java/com/platform/boot/security/core/user/UsersRepository.java b/boot/platform/src/main/java/com/platform/boot/security/core/user/UsersRepository.java index 90f675fe..d0a8af25 100644 --- a/boot/platform/src/main/java/com/platform/boot/security/core/user/UsersRepository.java +++ b/boot/platform/src/main/java/com/platform/boot/security/core/user/UsersRepository.java @@ -6,7 +6,7 @@ import reactor.core.publisher.Mono; /** - * @author Alex bob(https://github.com/vnobo) + * @author AlexBob */ public interface UsersRepository extends R2dbcRepository { /** diff --git a/boot/platform/src/main/java/com/platform/boot/security/core/user/UsersService.java b/boot/platform/src/main/java/com/platform/boot/security/core/user/UsersService.java index 3cc9bab5..d9b12cfc 100644 --- a/boot/platform/src/main/java/com/platform/boot/security/core/user/UsersService.java +++ b/boot/platform/src/main/java/com/platform/boot/security/core/user/UsersService.java @@ -54,7 +54,7 @@ public Mono loadByCode(String code) { public Mono add(UserRequest request) { return this.usersRepository.existsByUsernameIgnoreCase(request.getUsername()).flatMap(exists -> { if (exists) { - return Mono.error(RestServerException.withMsg(1101, "User already exists", + return Mono.error(RestServerException.withMsg(417, "User already exists", "Username [" + request.getUsername() + "] already exists!")); } return this.operate(request); @@ -110,7 +110,6 @@ public Mono save(User user) { private String upgradeEncodingIfPassword(String password) { if (StringUtils.hasLength(password) && this.passwordEncoder.upgradeEncoding(password)) { - // Encode the password return this.passwordEncoder.encode(password); } return password; diff --git a/boot/platform/src/main/java/com/platform/boot/security/filter/CaptchaFilter.java b/boot/platform/src/main/java/com/platform/boot/security/filter/CaptchaFilter.java index 970ee892..b24f9d00 100644 --- a/boot/platform/src/main/java/com/platform/boot/security/filter/CaptchaFilter.java +++ b/boot/platform/src/main/java/com/platform/boot/security/filter/CaptchaFilter.java @@ -44,8 +44,7 @@ public CaptchaFilter(CaptchaRepository captchaTokenRepository) { } @Override - @NonNull - public Mono filter(@NonNull ServerWebExchange exchange, @NonNull WebFilterChain chain) { + public @NonNull Mono filter(@NonNull ServerWebExchange exchange, @NonNull WebFilterChain chain) { return REQUIRE_CAPTCHA_PROTECTION_MATCHER.matches(exchange) .filter(ServerWebExchangeMatcher.MatchResult::isMatch) .switchIfEmpty(Mono.defer(() -> continueFilterChain(exchange, chain).then(Mono.empty())))