[opencms-dev] preview offline project w/o logging in?

Christian Steinert christian_steinert at web.de
Thu Sep 28 11:00:32 CEST 2006


Marcus Popetz schrieb:
> My client wants to know if there is a way to send a url around for
> people to preview what is in the offline project without having to
> give them access to opencms and make them navigate to it and such.
>
> The url could contain a username/password, they'd accept that.
> They're just trying to avoid teaching the powers-that-be how to
> navigate within opencms.
>
> Anyone crossed this bridge?
>
> -mp
Afaik, you cannot view offline content without being logged in.
I also think the best idea would be to have a small script that does
frontend login. If the parameters are given from outside, then it could
log users into offline mode without even asking and redirect to a given
page after that.



Here is the login code again, that i am using. If you don't want that
the system asks for login then you can just append the parameters
   user, password, url
to the URL, for example:
  
www.whatever.com/frontentlogin.jsp?user=demo&password=4837fhiod&url=/index.html

Please note, that for some browsers a reload of the page might be
required, if the same page had been viewed in online mode recently by
the same user.
Without reload, the user might still see the cached online version of
your page.

hth
christian

===frontendlogin.jsp====================================================
cms.getCmsObject() -->
<%@ 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)) {
         %><html><head><title>Frontend login</title></head><body
onload="document.forms[0].elements[0].focus()"><h1>please
login:</h1><form method="post">
            <p>username: <input name="user" /></p>
            <p>password: <input name="password" type="password" /></p>
            <p><input type="submit"/></p>
           </form></body></html><%

   } else {

     CmsObject cmsObject = cms.getCmsObject();
     cmsObject.loginUser(user, password);
     CmsProject cmsproject = cmsObject.readProject("Offline");
     cmsObject.getRequestContext().setCurrentProject(cmsproject);
     cmsObject.getRequestContext().setSiteRoot("/sites/default");

    if( url!=null && url.length()>0 )
       response.sendRedirect(url);
     else
       response.sendRedirect(cms.link("/index.html"));
   %>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3269 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20060928/719836ee/attachment.bin>


More information about the opencms-dev mailing list