use of org.orcid.pojo.ajaxForm.RequestInfoForm 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.getEmailsAdditional().get(0).setRequired(false);
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);
Boolean isOauth2ScreensRequest = (Boolean) request.getSession().getAttribute(OrcidOauth2Constants.OAUTH_2SCREENS);
if (isOauth2ScreensRequest != null) {
reg.setCreationType(Text.valueOf(CreationMethod.MEMBER_REFERRED.value()));
} else {
reg.setCreationType(Text.valueOf(CreationMethod.DIRECT.value()));
}
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