| Line 107... |
Line 107... |
| 107 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
107 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 108 |
public ResponseEntity<?> tokenInfo(HttpServletRequest request) throws Throwable {
|
108 |
public ResponseEntity<?> tokenInfo(HttpServletRequest request) throws Throwable {
|
| 109 |
Map<String, Object> responseMap = new HashMap<>();
|
109 |
Map<String, Object> responseMap = new HashMap<>();
|
| 110 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
110 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 111 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
111 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 112 |
if (userInfo.getEmail() == null) {
|
112 |
if (userInfo.getUserId() > 0) {
|
| 113 |
User user = userRepository.selectById(userInfo.getUserId());
|
113 |
User user = userRepository.selectById(userInfo.getUserId());
|
| 114 |
responseMap.put(ProfitMandiConstants.EMAIL_ID, user.getEmailId());
|
114 |
responseMap.put(ProfitMandiConstants.EMAIL_ID, user.getEmailId());
|
| 115 |
responseMap.put(ProfitMandiConstants.USER_ID, user.getId());
|
115 |
responseMap.put(ProfitMandiConstants.USER_ID, user.getId());
|
| 116 |
// if user is retailer
|
116 |
// if user is retailer
|
| 117 |
if (user.getRoles().stream().anyMatch(new Predicate<Role>() {
|
117 |
if (user.getRoles().stream().anyMatch(new Predicate<Role>() {
|
| Line 137... |
Line 137... |
| 137 |
public boolean test(Role t) {
|
137 |
public boolean test(Role t) {
|
| 138 |
return t.getType().equals(RoleType.USER);
|
138 |
return t.getType().equals(RoleType.USER);
|
| 139 |
}
|
139 |
}
|
| 140 |
})) {
|
140 |
})) {
|
| 141 |
responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.REGISTERED.getValue());
|
141 |
responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.REGISTERED.getValue());
|
| - |
|
142 |
} else {
|
| - |
|
143 |
responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.RETAILER.getValue());
|
| 142 |
}
|
144 |
}
|
| 143 |
} else {
|
145 |
} else {
|
| 144 |
responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.NOT_REGISTERED.getValue());
|
146 |
responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.NOT_REGISTERED.getValue());
|
| 145 |
responseMap.put(ProfitMandiConstants.EMAIL_ID, userInfo.getEmail());
|
147 |
responseMap.put(ProfitMandiConstants.EMAIL_ID, userInfo.getEmail());
|
| 146 |
}
|
148 |
}
|