Skip to content

Commit

Permalink
New confirmation token ident generation logic (#998)
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksandr Muravja <[email protected]>
  • Loading branch information
kyberorg committed Feb 13, 2023
1 parent 9563458 commit eabcf0d
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/main/java/pm/axe/core/IdentGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ public final class IdentGenerator {
public static final String VALID_IDENT_PATTERN = "^[a-zA-Z0-9]([._-](?![._-])|[a-zA-Z0-9]){0,"
+ IDENT_MAX_LENGTH_WITHOUT_FIRST_AND_LAST_CHARS + "}[a-zA-Z0-9]$";

private static final int TOKEN_SUBSTRING_START_INDEX = 0;
private static final int TOKEN_SUBSTRING_END_INDEX = 5;

private IdentGenerator() {
throw new UnsupportedOperationException("Utility class");
}
Expand Down Expand Up @@ -68,8 +65,7 @@ public static String generateTokenIdent(final Token token) {

private static String generateAccountConfirmationIdent(final Token token) {
String prefix = token.getTokenType().getIdentPrefix();
String firstPartOfToken = token.getToken().substring(TOKEN_SUBSTRING_START_INDEX, TOKEN_SUBSTRING_END_INDEX);
String randomPart = RandomStringUtils.randomAlphanumeric(2); //for re-used tokens
return String.join("", prefix, firstPartOfToken, randomPart);
String randomPart = RandomStringUtils.randomAlphanumeric(Axe.C.FOUR);
return String.join("", prefix, randomPart);
}
}

0 comments on commit eabcf0d

Please sign in to comment.