use of org.orcid.pojo.ajaxForm.Registration in project ORCID-Source by ORCID.
the class RegistrationManagerImplTest method testCreateMinimalRegistrationWithExistingUnclaimedEmailNotAutoDeprecatable.
@Test
public void testCreateMinimalRegistrationWithExistingUnclaimedEmailNotAutoDeprecatable() {
//Create the user, but set it as unclaimed
String email = "new_user_" + System.currentTimeMillis() + "@test.orcid.org";
//Create a record by a member
OrcidProfile orcidProfile = createBasicProfile(email, false, CLIENT_ID_AUTODEPRECATE_DISABLED);
orcidProfile = orcidProfileManager.createOrcidProfile(orcidProfile, true, true);
assertNotNull(orcidProfile);
assertNotNull(orcidProfile.getOrcidIdentifier());
assertNotNull(orcidProfile.getOrcidIdentifier().getPath());
try {
Registration form = createRegistrationForm(email, true);
registrationManager.createMinimalRegistration(form, true, java.util.Locale.ENGLISH, "0.0.0.0");
fail();
} catch (InvalidRequestException e) {
assertEquals("Unable to register user due: Autodeprecate is not enabled for " + email, e.getMessage());
} catch (Exception e) {
fail();
}
}
use of org.orcid.pojo.ajaxForm.Registration in project ORCID-Source by ORCID.
the class RegistrationManagerImplTest method createRegistrationForm.
private Registration createRegistrationForm(String email, boolean claimed) {
Registration registration = new Registration();
registration.setPassword(Text.valueOf("password"));
registration.setEmail(Text.valueOf(email));
registration.setFamilyNames(Text.valueOf("User"));
registration.setGivenNames(Text.valueOf("New"));
registration.setCreationType(Text.valueOf(CreationMethod.DIRECT.value()));
return registration;
}
use of org.orcid.pojo.ajaxForm.Registration in project ORCID-Source by ORCID.
the class RegistrationController method getRegister.
@RequestMapping(value = "/register.json", method = RequestMethod.GET)
@ResponseBody
public Registration getRegister(HttpServletRequest request, HttpServletResponse response) {
// Remove the session hash if needed
if (request.getSession().getAttribute(GRECAPTCHA_SESSION_ATTRIBUTE_NAME) != null) {
request.getSession().removeAttribute(GRECAPTCHA_SESSION_ATTRIBUTE_NAME);
}
Registration reg = new Registration();
reg.getEmail().setRequired(true);
reg.getEmailConfirm().setRequired(true);
reg.getFamilyNames().setRequired(false);
reg.getGivenNames().setRequired(true);
reg.getSendChangeNotifications().setValue(true);
reg.getSendOrcidNews().setValue(true);
reg.getSendMemberUpdateRequests().setValue(true);
reg.getSendEmailFrequencyDays().setValue(SendEmailFrequency.WEEKLY.value());
reg.getTermsOfUse().setValue(false);
setError(reg.getTermsOfUse(), "validations.acceptTermsAndConditions");
RequestInfoForm requestInfoForm = (RequestInfoForm) request.getSession().getAttribute(OauthControllerBase.REQUEST_INFO_FORM);
if (requestInfoForm != null) {
if (!PojoUtil.isEmpty(requestInfoForm.getUserEmail())) {
reg.getEmail().setValue(requestInfoForm.getUserEmail());
}
if (!PojoUtil.isEmpty(requestInfoForm.getUserGivenNames())) {
reg.getGivenNames().setValue(requestInfoForm.getUserGivenNames());
}
if (!PojoUtil.isEmpty(requestInfoForm.getUserFamilyNames())) {
reg.getFamilyNames().setValue(requestInfoForm.getUserFamilyNames());
}
}
long numVal = generateRandomNumForValidation();
reg.setValNumServer(numVal);
reg.setValNumClient(0);
return reg;
}
Aggregations