| Total Complexity | 5 |
| Total Lines | 29 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | package easytests.auth.services; |
||
| 15 | @Service |
||
| 16 | public class SessionService implements SessionServiceInterface { |
||
| 17 | |||
| 18 | @Autowired |
||
| 19 | protected UsersServiceInterface usersService; |
||
| 20 | |||
| 21 | private Boolean userModelFetched = false; |
||
| 22 | |||
| 23 | private UserModelInterface userModel; |
||
| 24 | |||
| 25 | @Override |
||
| 26 | public Boolean isUser() { |
||
| 27 | return this.isUser(this.getUserModel()); |
||
| 28 | } |
||
| 29 | |||
| 30 | private Boolean isUser(UserModelInterface userModel) { |
||
| 31 | return userModel != null; |
||
| 32 | } |
||
| 33 | |||
| 34 | @Override |
||
| 35 | public UserModelInterface getUserModel() { |
||
| 36 | if (!this.userModelFetched) { |
||
| 37 | final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); |
||
| 38 | if (!(authentication instanceof AnonymousAuthenticationToken)) { |
||
| 39 | this.userModel = usersService.findByEmail(authentication.getName()); |
||
| 40 | } |
||
| 41 | this.userModelFetched = true; |
||
| 42 | } |
||
| 43 | return this.userModel; |
||
| 44 | } |
||
| 46 |