Skip to content

Commit

Permalink
feat(sandside): #198 limit the number of generated passwords
Browse files Browse the repository at this point in the history
  • Loading branch information
Marthym committed Jan 14, 2024
1 parent c3035da commit a79c72d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @param self The Persisted Entity
* @param <T> The type of the persisted object
*/
@Builder(toBuilder = true)
@Builder
public record Entity<T>(
@NonNull String id,
@NonNull String createdBy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ public Mono<PasswordEvaluation> checkPasswordStrength(User user) {

@Override
public Flux<String> generateSecurePassword(int number) {
if (number > 100 || number < 1) {
return Flux.error(() -> new IllegalArgumentException("Invalid number of passwords required !"));
}
return Flux.<String>create(sink ->
sink.onRequest(n -> LongStream.range(0, number)
.mapToObj(ignore -> passwordChecker.generate())
.forEach(sink::next)))
.take(Integer.valueOf(number).longValue());
.take(number);
}
}

0 comments on commit a79c72d

Please sign in to comment.