This commit is contained in:
Parpaillax
2024-04-24 16:53:04 +02:00
parent 30dcb2abad
commit 119c45b3ec
6 changed files with 50 additions and 35 deletions

View File

@@ -27,7 +27,9 @@ public class UserInterceptor implements HandlerInterceptor {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication != null && authentication.isAuthenticated() && !authentication.getName().equals("anonymousUser")) {
UserProfil user = this.userService.utilisateurByName(authentication.getName());
modelAndView.getModelMap().addAttribute("user", user.getCredit());
if (modelAndView != null && modelAndView.getViewName() != null && !modelAndView.getViewName().startsWith("redirect:")) {
modelAndView.addObject("user", user.getCredit());
}
}
}
}

View File

@@ -1,13 +0,0 @@
//package fr.eni.enchere.interceptor;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
//
//public class UserServiceInterceptorAppConfig implements WebMvcConfigurer {
//
// @Override
// public void addInterceptors(InterceptorRegistry registry) {
// registry.addInterceptor(new UserInterceptor());
// }
//}