|
6 | 6 | import java.util.Locale; |
7 | 7 |
|
8 | 8 | import javax.annotation.Resource; |
| 9 | +import javax.persistence.NoResultException; |
9 | 10 | import javax.servlet.http.HttpServletRequest; |
10 | 11 | import javax.servlet.http.HttpServletResponse; |
11 | 12 |
|
12 | 13 | import org.apache.commons.codec.binary.Base64; |
| 14 | +import org.apache.jena.sparql.function.library.e; |
13 | 15 | import org.jasypt.exceptions.EncryptionOperationNotPossibleException; |
14 | 16 | import org.orcid.core.exception.OrcidBadRequestException; |
15 | 17 | import org.orcid.core.manager.EncryptionManager; |
|
27 | 29 | import org.slf4j.Logger; |
28 | 30 | import org.slf4j.LoggerFactory; |
29 | 31 | import org.springframework.beans.factory.annotation.Value; |
| 32 | +import org.springframework.http.ResponseEntity; |
30 | 33 | import org.springframework.security.authentication.AuthenticationManager; |
31 | 34 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
32 | 35 | import org.springframework.security.core.Authentication; |
@@ -201,23 +204,35 @@ public ModelAndView viewResendClaimEmail(@RequestParam(value = "email", required |
201 | 204 | String email = resendClaimRequest.getEmail(); |
202 | 205 | List<String> errors = new ArrayList<>(); |
203 | 206 | resendClaimRequest.setErrors(errors); |
204 | | - |
205 | | - if (!OrcidStringUtils.isEmailValid(email)) { |
206 | | - errors.add(getMessage("Email.resetPasswordForm.invalidEmail")); |
207 | | - return resendClaimRequest; |
208 | | - } |
209 | 207 |
|
210 | | - if (!emailManager.emailExists(email)) { |
211 | | - String message = getMessage("orcid.frontend.reset.password.email_not_found_1") + " " + email + " " + getMessage("orcid.frontend.reset.password.email_not_found_2"); |
212 | | - message += "<a href=\"https://support.orcid.org/\">"; |
213 | | - message += getMessage("orcid.frontend.reset.password.email_not_found_3"); |
214 | | - message += "</a>"; |
215 | | - message += getMessage("orcid.frontend.reset.password.email_not_found_4"); |
216 | | - errors.add(message); |
217 | | - return resendClaimRequest; |
| 208 | + String orcid = null; |
| 209 | + if (OrcidStringUtils.isValidOrcid(email)) { |
| 210 | + try{ |
| 211 | + orcid = email; |
| 212 | + email = emailManager.findPrimaryEmail(orcid).getEmail(); |
| 213 | + } catch(NoResultException nre) { |
| 214 | + errors.add(getMessage("Email.resetPasswordForm.error")); |
| 215 | + return resendClaimRequest; |
| 216 | + } |
| 217 | + } else { |
| 218 | + if (!OrcidStringUtils.isEmailValid(email)) { |
| 219 | + errors.add(getMessage("Email.resetPasswordForm.invalidEmail")); |
| 220 | + return resendClaimRequest; |
| 221 | + } |
| 222 | + |
| 223 | + if (!emailManager.emailExists(email)) { |
| 224 | + String message = getMessage("orcid.frontend.reset.password.email_not_found_1") + " " + email + " " + getMessage("orcid.frontend.reset.password.email_not_found_2"); |
| 225 | + message += "<a href=\"https://support.orcid.org/\">"; |
| 226 | + message += getMessage("orcid.frontend.reset.password.email_not_found_3"); |
| 227 | + message += "</a>"; |
| 228 | + message += getMessage("orcid.frontend.reset.password.email_not_found_4"); |
| 229 | + errors.add(message); |
| 230 | + return resendClaimRequest; |
| 231 | + } |
| 232 | + |
| 233 | + orcid = emailManager.findOrcidIdByEmail(email); |
218 | 234 | } |
219 | | - |
220 | | - String orcid = emailManager.findOrcidIdByEmail(email); |
| 235 | + |
221 | 236 | ProfileEntity profile = profileEntityCacheManager.retrieve(orcid); |
222 | 237 |
|
223 | 238 | if (profile != null && profile.getClaimed()) { |
|
0 commit comments