Skip to content

Commit

Permalink
Idporten userinfo request mer logging
Browse files Browse the repository at this point in the history
#deploy-dolly-backend
  • Loading branch information
stigus committed Aug 23, 2024
1 parent c98197c commit a6a8967
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import java.util.Optional;
import java.util.concurrent.Callable;

import static java.util.Objects.isNull;

@Slf4j
@Component
public class GetUserInfo implements Callable<Optional<UserInfo>> {
Expand All @@ -25,7 +27,12 @@ public GetUserInfo(@Value("${JWT_SECRET:#{null}}") String secret) {

@Override
public Optional<UserInfo> call() {
var request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
var requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
if (isNull(requestAttributes)) {
log.warn("Fant ikke request attributes i context.");
return Optional.empty();
}
var request = requestAttributes.getRequest();
log.trace("Prøver å hente JWT fra request...");
return Optional.ofNullable(request.getHeader(UserConstant.USER_HEADER_JWT)).map(token -> {
log.trace("Fant JWT i request.");
Expand Down

0 comments on commit a6a8967

Please sign in to comment.