[opencms-dev] how to handle webuser login?

Christoph P. Kukulies kuku at physik.rwth-aachen.de
Fri Jul 7 16:59:35 CEST 2006


On Fri, Jul 07, 2006 at 04:52:19PM +0200, Siegfried Puchbauer wrote:
> There is also a property called "login-form" where you can put in the uri of
> a login form (eg /login/). You can set this property eg. in the root folder
> of a site and the subfolders inherit it.
> When you hit a protected resource, opencms redirect you to this login form.
> The login form receives  GET Parameters like:
> /login/?__loginform=true&requestedResource=%2Frestricted_area%2Fsubfolder%2F
> 
> All you have to implement is a form (which also forwards the parameters) and
> a login handler page like:
> 
> <%@ page session="true" import="org.opencms.jsp.*" %><%
> CmsJspLoginBean cms = new CmsJspLoginBean(pageContext, request, response);
> org.opencms.file.CmsObject obj = cms.getCmsObject();
> String requestedPage= request.getParameter("requestedResource");
> 
>        try{
>            obj.loginWebUser(request.getParameter("login_username"),
> request.getParameter("login_password"));
>            response.sendRedirect(cms.link(requestedPage));
>        }catch(org.opencms.main.CmsException e){
>            response.sendRedirect(cms.link(cms.property("login-form",
> "search")) + "?message=" + e.getLocalizedMessage(java.util.Locale.GERMAN));
>        }
> %>
> 
> This way its very easy to replace the default browser auth-popup with a html
> form
> 

This is cute :-) Thanks.

--
Chris Christoph P. U. Kukulies kukulies (at) rwth-aachen.de



More information about the opencms-dev mailing list