| @@ 162-175 (lines=14) @@ | ||
| 159 | return tokenResponseDTO; |
|
| 160 | } |
|
| 161 | ||
| 162 | void deleteToken(String token, String remoteAddr) { |
|
| 163 | final List<InUserLogin> inUserLogins = inUserLoginRepository.findByToken(token); |
|
| 164 | if (!inUserLogins.isEmpty()) { |
|
| 165 | final List<InUserLogout> inUserLogouts = inUserLogoutRepository.findByToken(token); |
|
| 166 | if (!inUserLogouts.isEmpty()) { |
|
| 167 | throw new UnauthorizedException("Invalid token"); |
|
| 168 | } |
|
| 169 | InUserLogout inUserLogout = new InUserLogout(); |
|
| 170 | inUserLogout.setToken(token); |
|
| 171 | inUserLogout.setInUser(inUserLogins.get(inUserLogins.size() - 1).getInUser()); |
|
| 172 | inUserLogout.setIp_address(remoteAddr); |
|
| 173 | inUserLogoutRepository.saveAndFlush(inUserLogout); |
|
| 174 | } else { |
|
| 175 | throw new UnauthorizedException("Token not found"); |
|
| 176 | } |
|
| 177 | } |
|
| 178 | } |
|
| @@ 138-151 (lines=14) @@ | ||
| 135 | return tokenEmailResponseDTO; |
|
| 136 | } |
|
| 137 | ||
| 138 | void deleteToken(String token, String remoteAddr) { |
|
| 139 | final List<InUserLogin> inUserLogins = inUserLoginRepository.findByToken(token); |
|
| 140 | if (!inUserLogins.isEmpty()) { |
|
| 141 | final List<InUserLogout> inUserLogouts = inUserLogoutRepository.findByToken(token); |
|
| 142 | if (!inUserLogouts.isEmpty()) { |
|
| 143 | throw new UnauthorizedException("Invalid token"); |
|
| 144 | } |
|
| 145 | InUserLogout inUserLogout = new InUserLogout(); |
|
| 146 | inUserLogout.setToken(token); |
|
| 147 | inUserLogout.setInUser(inUserLogins.get(inUserLogins.size() - 1).getInUser()); |
|
| 148 | inUserLogout.setIp_address(remoteAddr); |
|
| 149 | inUserLogoutRepository.saveAndFlush(inUserLogout); |
|
| 150 | } else { |
|
| 151 | throw new UnauthorizedException("Token not found"); |
|
| 152 | } |
|
| 153 | } |
|
| 154 | } |
|