Skip to content

Commit 2a9afc7

Browse files
committed
Removed unused token service
1 parent 3da0bf5 commit 2a9afc7

File tree

3 files changed

+10
-19
lines changed

3 files changed

+10
-19
lines changed

src/main/java/org/openpodcastapi/opa/auth/ApiAuthController.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import jakarta.validation.constraints.NotNull;
55
import lombok.RequiredArgsConstructor;
66
import lombok.extern.log4j.Log4j2;
7-
import org.openpodcastapi.opa.security.JwtService;
87
import org.openpodcastapi.opa.security.TokenService;
98
import org.openpodcastapi.opa.user.UserEntity;
109
import org.openpodcastapi.opa.user.UserRepository;
@@ -21,8 +20,6 @@
2120
@RequiredArgsConstructor
2221
@Log4j2
2322
public class ApiAuthController {
24-
25-
private final JwtService jwtService;
2623
private final TokenService tokenService;
2724
private final UserRepository userRepository;
2825
private final AuthenticationManager authenticationManager;
@@ -45,7 +42,7 @@ public ResponseEntity<AuthDTO.LoginSuccessResponse> login(@RequestBody @NotNull
4542
String refreshToken = tokenService.generateRefreshToken(userEntity);
4643

4744
// Format the tokens and expiration time into a DTO
48-
AuthDTO.LoginSuccessResponse response = new AuthDTO.LoginSuccessResponse(accessToken, refreshToken, String.valueOf(jwtService.getExpirationTime()));
45+
AuthDTO.LoginSuccessResponse response = new AuthDTO.LoginSuccessResponse(accessToken, refreshToken, String.valueOf(tokenService.getExpirationTime()));
4946

5047
return ResponseEntity.ok(response);
5148
}
@@ -61,7 +58,7 @@ public ResponseEntity<AuthDTO.RefreshTokenResponse> getRefreshToken(@RequestBody
6158
String newAccessToken = tokenService.generateAccessToken(userEntity);
6259

6360
// Format the token and expiration time into a DTO
64-
AuthDTO.RefreshTokenResponse response = new AuthDTO.RefreshTokenResponse(newAccessToken, String.valueOf(jwtService.getExpirationTime()));
61+
AuthDTO.RefreshTokenResponse response = new AuthDTO.RefreshTokenResponse(newAccessToken, String.valueOf(tokenService.getExpirationTime()));
6562

6663
return ResponseEntity.ok(response);
6764
}

src/main/java/org/openpodcastapi/opa/security/JwtService.java

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/main/java/org/openpodcastapi/opa/security/TokenService.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,19 @@ public class TokenService {
3333
@Value("${jwt.refresh-days:7}")
3434
private long refreshTokenDays;
3535

36+
@Value("${jwt.ttl}")
37+
private String jwtExpiration;
38+
3639
// The calculated secret key
3740
private SecretKey key() {
3841
return Keys.hmacShaKeyFor(secret.getBytes(StandardCharsets.UTF_8));
3942
}
4043

44+
/// Returns the expiration time for JWTs
45+
public long getExpirationTime() {
46+
return Long.parseLong(jwtExpiration);
47+
}
48+
4149
/// Generates an access token for a given userEntity
4250
///
4351
/// @param userEntity the [UserEntity] to generate a token for

0 commit comments

Comments
 (0)