R: [opencms-dev] Multi Site Login problem - REVISED
Mario D'Angelo
mario.dangelo at e-dea.it
Mon Sep 11 19:32:37 CEST 2006
Christian,
Thank you for your support in the first place, but off course I have used
the setSiteRoot as you adviced with no results.
Just to understand each other better. The following script works just
perfectly if the Site that includes the login_elements.jsp is the same as
the one set in the opencms-workplace.xml:
<workplace-startupsettings>
<locale>en</locale>
<project>Offline</project>
<workplaceview>/system/workplace/views/explorer/explorer_fs.jsp</
workplaceview>
<folder>/</folder>
<site>/sites/InfoNet/</site>
<restrictexplorerview>false</restrictexplorerview>
</workplace-startupsettings>
But than it doesn't work for the other site and vice versa. So for example
if I set <site>/sites/InfoNet/</site> to
<site>/sites/Provincia_di_Napoli/</site>, the login will work for the site
Provincia_di_Napoli but it wont work for the site InfoNet. This is the
issue.
PS
It seems opencms really does't give a s... about the setSiteRoot thing.
Here is the login_elements.jsp code, which I repeat works great, the only
problem is with Multisites.
-----------------------------------------------------------------------
BEGIN: login_elements.jsp
-----------------------------------------------------------------------
<%@ page session="false" import="java.lang.*, java.util.*,
org.opencms.jsp.*, org.opencms.file.*, org.opencms.site.*" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%
// get required OpenCms objects
CmsJspLoginBean cms = new CmsJspLoginBean(pageContext, request, response);
CmsJspActionElement cmsJsp = new CmsJspActionElement(pageContext, request,
response);
CmsProject prjObj = cmsObj.readProject("Offline");
// read parameters from the request
String username = request.getParameter("username");
String password = request.getParameter("password");
String action = request.getParameter("action");
boolean hideLoginForm =
Boolean.valueOf(request.getParameter("hideloginform")).booleanValue();
String curFolder = cmsJsp.info("opencms.request.folder");
String login_redirect =
"/opencms/opencms/system/workplace/commons/displayresource.jsp?resource=" +
curFolder + "index.html";
// now process the login data
if ("logout".equals(action))
{
cms.logout();
}
else if ("login".equals(action))
{
cms.login(username, password);
if (cms.isLoginSuccess())
{
cms.getRequestContext().setCurrentProject(prjObj);
cms.getRequestContext().setSiteRoot("/sites/InfoNet");
response.sendRedirect(cmsJsp.link(login_redirect));
}
}
if (! cms.isLoggedIn() && ! hideLoginForm)
{
String message = "Accesso Area Riservata";
if (! cms.isLoginSuccess())
{
// previous login attempt was not successful
message = "Accesso fallito, perfavore riprova:";
}
%>
<form action="<%= cms.getFormLink() %>" method="POST">
<table border="0" cellpadding="2" cellspacing="0">
<tr><td class="tdCaption" colspan="3">Accesso Area Riservata</td></tr>
<tr><td class="tdLabelMid">Nome Utente:</td><td colspan="2"><input
class="search" name="username" value="<%= username!=null?username:""
%>"></td></tr>
<tr><td class="tdLabelBot">Password:</td><td class="tdBot"><input
class="search" name="password" type="password"></td><td class="tdBot"><input
class="formbutton" type="submit" value="Login"><input type="hidden"
name="action" value="login"></td></tr>
</table>
</form>
<%
}
else if (! hideLoginForm)
{
// current user is already logged in - display the logout form
%>
<form action="<%= cms.getFormLink() %>" method="POST">
<table border="0" cellpadding="2" cellspacing="0">
<tr><td class="tdCaption" colspan="2">Accesso Autorizzato</td></tr>
<tr><td class="tdLabelMid">Nome Utente:</td><td><%= cms.getUserName()
%></td></tr>
<tr><td class="tdBotCenter" colspan="2"><input class="formbutton"
type="submit" value="Logout"><input type="hidden" name="action"
value="logout"></td></tr>
</table>
</form>
<cms:include file="/template_elements/nav_right_adm.jsp">
</cms:include>
<%
}
%>
-----------------------------------------------------------------------
END: login_elements.jsp
-----------------------------------------------------------------------
I REALLY HOPE SOMEBODY CAN FIGURE THIS OUT.
Thank you everybody again, especially Christian,
Regards,
Mario D'Angelo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20060911/ad6a2730/attachment.htm>
More information about the opencms-dev
mailing list