Search in sources :

Example 11 with RequestInfoForm

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;
}
Also used : Registration(org.orcid.pojo.ajaxForm.Registration) RequestInfoForm(org.orcid.pojo.ajaxForm.RequestInfoForm) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

RequestInfoForm (org.orcid.pojo.ajaxForm.RequestInfoForm)11 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 RedirectView (org.springframework.web.servlet.view.RedirectView)7 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)6 Authentication (org.springframework.security.core.Authentication)5 HashMap (java.util.HashMap)4 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)4 HttpSessionRequestCache (org.springframework.security.web.savedrequest.HttpSessionRequestCache)4 SimpleSessionStatus (org.springframework.web.bind.support.SimpleSessionStatus)4 LockedException (org.orcid.core.security.aop.LockedException)3 InvalidScopeException (org.springframework.security.oauth2.common.exceptions.InvalidScopeException)3 ModelAndView (org.springframework.web.servlet.ModelAndView)3 Locale (java.util.Locale)2 Registration (org.orcid.pojo.ajaxForm.Registration)2 Text (org.orcid.pojo.ajaxForm.Text)2 RedirectMismatchException (org.springframework.security.oauth2.common.exceptions.RedirectMismatchException)2 AuthorizationRequest (org.springframework.security.oauth2.provider.AuthorizationRequest)2 SavedRequest (org.springframework.security.web.savedrequest.SavedRequest)2 Principal (java.security.Principal)1 HashSet (java.util.HashSet)1