| Total Complexity | 3 |
| Total Lines | 19 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | package easytests.common.controllers; |
||
| 16 | @Controller |
||
| 17 | public class AbstractPersonalController { |
||
| 18 | @Autowired |
||
| 19 | protected UsersService usersService; |
||
| 20 | |||
| 21 | private UserModelInterface userModel; |
||
| 22 | |||
| 23 | private Boolean userModelFetched = false; |
||
| 24 | |||
| 25 | @ModelAttribute("currentUserModel") |
||
| 26 | public UserModelInterface getCurrentUserModel() { |
||
| 27 | if (!this.userModelFetched) { |
||
| 28 | final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); |
||
| 29 | if (!(authentication instanceof AnonymousAuthenticationToken)) { |
||
| 30 | this.userModel = usersService.findByEmail(authentication.getName()); |
||
| 31 | } |
||
| 32 | this.userModelFetched = true; |
||
| 33 | } |
||
| 34 | return this.userModel; |
||
| 35 | } |
||
| 37 |