Package com.espacogeek.geek.services
Interface JwtTokenService
- All Known Implementing Classes:
JwtTokenServiceImpl
public interface JwtTokenService
Interface for JwtTokenService to manage JWT tokens for multi-device support.
-
Method Summary
Modifier and TypeMethodDescriptionintClean up expired tokens.voiddeleteToken(String token) Delete a specific token.voiddeleteUserTokens(Integer userId) Delete all tokens for a user.findByToken(String token) Find a token by its value.findByUserId(Integer userId) Get all tokens for a user.booleanisTokenValid(String token) Validate if a token exists and is not expired.Save a new JWT token.
-
Method Details
-
saveToken
Save a new JWT token.- Parameters:
token- the JWT token stringuser- the user associated with the tokendeviceInfo- optional device information- Returns:
- the saved JwtTokenModel
-
isTokenValid
Validate if a token exists and is not expired.- Parameters:
token- the JWT token string- Returns:
- true if valid, false otherwise
-
findByToken
Find a token by its value.- Parameters:
token- the JWT token string- Returns:
- Optional containing the token model if found
-
findByUserId
Get all tokens for a user.- Parameters:
userId- the user ID- Returns:
- list of tokens for the user
-
deleteToken
Delete a specific token.- Parameters:
token- the JWT token string
-
deleteUserTokens
Delete all tokens for a user.- Parameters:
userId- the user ID
-
cleanupExpiredTokens
int cleanupExpiredTokens()Clean up expired tokens.- Returns:
- number of deleted tokens
-