[opencms-dev] how do i do a log user?

Lars Martin larsn at smb-tec.com
Tue Jan 25 11:00:12 CET 2005


-----Ursprüngliche Nachricht-----
Von: Tim Howland <thowland at organic.com>
Gesendet am: 21. Jan 2005, 16:15:01

> Hey Simone-
> 
> Here's my authentication routine:
> 
> <%@ page import="java.util.*" %>
> <%@ page import="com.opencms.file.*" %>
> <%@ page import="com.opencms.flex.jsp.*" %>
> <%@ page import="com.opencms.core.*" %>
> 
> 
> <%
> CmsJspActionElement cmsJsp = new CmsJspActionElement(pageContext,
> request, response);
> String myFolder = cmsJsp.info("opencms.request.folder");
> CmsObject cms = cmsJsp.getCmsObject();
> String userid = request.getParameter("user");
> String passwd = request.getParameter("passwd");
> try {
> 	cms.loginUser(userid,passwd);
> 	out.println("User logged in<br>");
> 	response.sendRedirect(cmsJsp.link("/secure/index.jsp"));
> }
> 
> catch (CmsException e) {
> 	response.sendRedirect("login.jsp");
> }
> %>
> 
> openCMS keeps the user's login state in it's session, so you don't have
> to muck around with it.
> 
> Every page on your site needs to check that the user is valid (put this
> into the page template):
> 
> <%
> CmsJspActionElement cmsJsp = new CmsJspActionElement(pageContext,
> request, response);
> if (cmsJsp.user("name").equals("Guest")) {
>      response.sendRedirect(cmsJsp.link("/login.jsp"));
> }
> %>

Hi Tim.

If have created a secure.jsp template containing the check for the
current user like above. All html pages in directory secure/ use this
secure.jsp template. If one opens a secured page without logging in
the login page should be opened via response.sendRedirect(). But in
my environment all users can open all secured pages - the redirect()
call doesn't seem to work. :o(
Do you have any hints? Thanks, Lars
______________________________________________________________________
Lars Martin                             mailto:Lars.Martin at smb-tec.com
SMB GmbH                                        http://www.smb-tec.com
D-04347 Leipzig                                    Rohrteichstrasse 18
Tel: +49-(0)341-699 46 04                    Fax: +49-(0)341-699 47 04
Produkt-Manager Business Server BS1          Produkt-Manager CADDA.NET





More information about the opencms-dev mailing list