Skip to content

Commit

Permalink
✨ feat: 更新用户服务以处理密码加密
Browse files Browse the repository at this point in the history
  • Loading branch information
vnobo committed May 30, 2024
1 parent e68eb8f commit ce449e3
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import reactor.core.publisher.Mono;

/**
* @author Alex bob(<a href="https://github.com/vnobo">https://github.com/vnobo</a>)
* @author <a href="https://github.com/vnobo">AlexBob</a>
*/
public interface UsersRepository extends R2dbcRepository<User, Long> {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public Mono<User> loadByCode(String code) {
public Mono<User> 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);
Expand Down Expand Up @@ -110,7 +110,6 @@ public Mono<User> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ public CaptchaFilter(CaptchaRepository captchaTokenRepository) {
}

@Override
@NonNull
public Mono<Void> filter(@NonNull ServerWebExchange exchange, @NonNull WebFilterChain chain) {
public @NonNull Mono<Void> 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())))
Expand Down

0 comments on commit ce449e3

Please sign in to comment.