掲示板

Custom registration portlet and redirect to login

7年前 に Odysseas Doumas によって更新されました。

Custom registration portlet and redirect to login

New Member 投稿: 17 参加年月日: 16/06/22 最新の投稿
I have created a custom JSF portlet that serves as a registration form. My goal is NOT to extend the default registration, this portlet is specific to our requirments, and it also registrers a new organization and some other custom Entitites. So far it works.

What i need now is, after the registration logic, to emulate the default registration portlet, redirect to the login page, and show the messages like "your password was sent to email etc etc". I managed to do the redirection but the SessionMessages are never shown. My code is this.

LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
		ExternalContext externalContext = liferayFacesContext.getExternalContext();
	
		PortletRequest portletRequest = liferayFacesContext.getPortletRequest();
		HttpServletRequest request = PortalUtil.getHttpServletRequest(portletRequest);

		long companyId = liferayFacesContext.getCompanyId();
		
		String registrationType = signInBackingBean.getRegistrationType();		
		User user = null;
		Organization registeredOrganization = null;

		try {

			ServiceContext serviceContext = ServiceContextFactory.getInstance(User.class.getName(),portletRequest);
			
			//Register user and organization
			user = registerUser(companyId, registrationType, liferayFacesContext, serviceContext);

			if (!registrationType.equals("")){
				registeredOrganization = registerOrganization(companyId, user, registrationType, serviceContext);
			}		
			
			
			// Session messages
			
			if (user.getStatus() == WorkflowConstants.STATUS_APPROVED) {
				_LOGGER.info("Approved");
				SessionMessages.add(
						request, "userAdded", user.getEmailAddress());
				SessionMessages.add(
						request, "userAddedPassword",
						user.getPasswordUnencrypted());
			}
			else {
				_LOGGER.info("Pending");
				SessionMessages.add(
						request, "userPending", user.getEmailAddress());
			}


			// Send redirect
			
			String login = null;
			String authType = PortalUtil.getCompany(request).getAuthType();

			if (authType.equals(CompanyConstants.AUTH_TYPE_ID)) {
				login = String.valueOf(user.getUserId());
			}
			else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) {
				login = user.getScreenName();
			}
			else {
				login = user.getEmailAddress();
			}

			PortletURL loginURL = getLoginURL(request, liferayFacesContext.getThemeDisplay().getPlid());
			loginURL.setParameter("login", login);
			String redirect = loginURL.toString();
			externalContext.redirect(redirect);

                       //Handle exceptions
			


My getLoginURL method is this (taken from the LoginUtil source)

	//Returns the URL for the Liferay login portlet
	private PortletURL getLoginURL(HttpServletRequest request, long plid)
			throws PortletModeException, WindowStateException {

		PortletURL portletURL = PortletURLFactoryUtil.create(
				request, PortletKeys.LOGIN, plid, PortletRequest.RENDER_PHASE);

		portletURL.setParameter("saveLastPath", Boolean.FALSE.toString());
		portletURL.setParameter("struts_action", "/login/login");
		portletURL.setPortletMode(PortletMode.VIEW);
		portletURL.setWindowState(WindowState.MAXIMIZED);

		return portletURL;
	}
thumbnail
7年前 に Neil Griffin によって更新されました。

RE: Custom registration portlet and redirect to login

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
I would recommend that you look at the source of the jsf-registration-portlet demo.