AuthContextService

@Service
class AuthContextService(jwtTokenService: JwtTokenService, tokenBlacklistService: TokenBlacklistService, productUserService: ProductUserService)

Utilities for inspecting and mutating the current authentication context.

  • isAuthenticated(): true when a non-anonymous Authentication is present.

  • logout(): best-effort blacklist of the presented access token and SecurityContext cleanup.

Constructors

Link copied to clipboard
constructor(jwtTokenService: JwtTokenService, tokenBlacklistService: TokenBlacklistService, productUserService: ProductUserService)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun getAuthenticatedProductUser(): ProductUser?
Link copied to clipboard

True if the current request has a real logged-in user. In other words: someone presented a valid access token and we recorded that user for this request.

Link copied to clipboard
Link copied to clipboard
fun logout()

Log the user out for this request by blacklisting the presented access token (if any) until it would naturally expire, and clearing Spring Security’s context. This does not delete the refresh cookie; the controller handles that.