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