[opencms-dev] Multi Site Login problem - REVISED

Mario D'Angelo mario.dangelo at e-dea.it
Mon Sep 11 13:53:24 CEST 2006


I posted a wrong version of the "login_element.jsp" code, so I am just
resending the right one. Sorry about that.

The posted code is just a simple element to debug login processes, so the
siteRoot, for example is static "/sites/InfoNet", the same code works
perfectly if the login_element is included in one of the pages of the
Workplace Default Site ie: "/sites/Provincia_di_Napoli/", or from the site
"/sites/InfoNet/" if I set the <workplace-startupsettings> site to
<site>/sites/InfoNet/</site>.

 

I have two Sites set: "/sites/Provincia_di_Napoli/" and "/sites/InfoNet/",
everything works great, but when I tried to perform a login from the online
site for editing content it works only if the login is performed from the
site set as default in the "opencms-workplace.xml" conf file es.:

 

<workplace-startupsettings>

<locale>en</locale>

            <project>Offline</project>

 
<workplaceview>/system/workplace/views/explorer/explorer_fs.jsp</workplacevi
ew>

            <folder>/</folder>

            <site>/sites/Provincia_di_Napoli/</site>

            <restrictexplorerview>false</restrictexplorerview>

</workplace-startupsettings> 

 

In this case the login works if I access from the site
http://demo.xdea.it:8082/ but doen't if I try to login form
http://192.168.1.160:8084/. I could fix the proble if only there was a way
to set the CURRENT SITE on the fly, but I couldn't find it. Can somebody
help me, please.

 

Here is the simple code for performing login operation:

 

<%@ page session="true" import="org.opencms.main.*, org.opencms.jsp.*,
org.opencms.file.*, java.lang.String" %>

<%

CmsJspActionElement cms = new
CmsJspActionElement(pageContext,request,response);

 

String user = request.getParameter("user");

String password = request.getParameter("password");

 

String url = request.getParameter("url");

 

//form not submitted? => show login form.

 

     if((user==null)||(user.length()==0))

     {

%>

<form method="post">

<p>username: <input name="user" /></p>

<p>password: <input name="password" type="password" /></p>

<p><input type="submit"/></p>

</form>

<%

     }

          else

          {

          CmsObject cmsObject = cms.getCmsObject();

          cmsObject.loginUser(user, password);

          CmsProject cmsproject = cmsObject.readProject("Offline");

          cmsObject.getRequestContext().setCurrentProject(cmsproject);

          cmsObject.getRequestContext().setSiteRoot("/sites/InfoNet");

          

          String curFolder = cms.info("opencms.request.folder");

          out.print("<br>Cur Folder: " + curFolder + "<br>");

          

          //curFolder = "Micro_Siti/XDEA_ADMIN/";

 

                          String login_redirect =
"/opencms/opencms/system/workplace/commons/displayresource.jsp?resource=" +
curFolder + "index.html";

          

            if( url!=null && url.length()>0 )

                        {

                        response.sendRedirect(url);

                        }

                        else

                        {

                        response.sendRedirect(cms.link(login_redirect));

                        }

          }

 

     

%>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20060911/1ca2a4b5/attachment.htm>


More information about the opencms-dev mailing list