From afe57215ccdc7b83ffbc32fa0567e882d17debd3 Mon Sep 17 00:00:00 2001 From: Vladik-gif Date: Thu, 17 Oct 2024 14:43:14 +0300 Subject: [PATCH] update: refactor project All --- src/main/java/com/chat/yourway/model/token/Token.java | 6 ++---- src/main/java/com/chat/yourway/model/token/TokenType.java | 5 ----- src/main/java/com/chat/yourway/security/JwtAuthFilter.java | 4 ++-- .../com/chat/yourway/service/AuthenticationService.java | 4 +--- 4 files changed, 5 insertions(+), 14 deletions(-) delete mode 100644 src/main/java/com/chat/yourway/model/token/TokenType.java diff --git a/src/main/java/com/chat/yourway/model/token/Token.java b/src/main/java/com/chat/yourway/model/token/Token.java index 44632fe7..013dbadc 100644 --- a/src/main/java/com/chat/yourway/model/token/Token.java +++ b/src/main/java/com/chat/yourway/model/token/Token.java @@ -16,14 +16,12 @@ @Setter @RedisHash("Token") public class Token { - @Id @Indexed public String email; @Indexed public String token; - public TokenType tokenType; + public String tokenType; public boolean revoked; public boolean expired; - -} +} \ No newline at end of file diff --git a/src/main/java/com/chat/yourway/model/token/TokenType.java b/src/main/java/com/chat/yourway/model/token/TokenType.java deleted file mode 100644 index 2ef14f81..00000000 --- a/src/main/java/com/chat/yourway/model/token/TokenType.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.chat.yourway.model.token; - -public enum TokenType { - BEARER -} diff --git a/src/main/java/com/chat/yourway/security/JwtAuthFilter.java b/src/main/java/com/chat/yourway/security/JwtAuthFilter.java index 0b332054..bacc89f6 100644 --- a/src/main/java/com/chat/yourway/security/JwtAuthFilter.java +++ b/src/main/java/com/chat/yourway/security/JwtAuthFilter.java @@ -35,8 +35,8 @@ public class JwtAuthFilter extends OncePerRequestFilter { @Override @SneakyThrows protected void doFilterInternal(@NonNull HttpServletRequest request, - @NonNull HttpServletResponse response, - @NonNull FilterChain filterChain) { + @NonNull HttpServletResponse response, + @NonNull FilterChain filterChain) { if (isNotAuthorizationHeader(request) && isNotTokenParameter(request)) { log.warn("Request without authorization. Header or parameter does not contain {}", AUTHORIZATION); diff --git a/src/main/java/com/chat/yourway/service/AuthenticationService.java b/src/main/java/com/chat/yourway/service/AuthenticationService.java index dc339b98..61ffe6bc 100644 --- a/src/main/java/com/chat/yourway/service/AuthenticationService.java +++ b/src/main/java/com/chat/yourway/service/AuthenticationService.java @@ -1,7 +1,5 @@ package com.chat.yourway.service; -import static com.chat.yourway.model.token.TokenType.*; - import com.chat.yourway.dto.request.AuthRequestDto; import com.chat.yourway.dto.request.ContactRequestDto; import com.chat.yourway.dto.request.EmailRequestDto; @@ -107,7 +105,7 @@ private void saveContactToken(String email, String jwtToken) { var token = Token.builder() .email(email) .token(jwtToken) - .tokenType(BEARER) + .tokenType("BEARER") .expired(false) .revoked(false) .build();