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

Tim Howland thowland at organic.com
Fri Jan 21 16:15:01 CET 2005


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"));
}
%>
 
HTH,

Tim
-----Original Message-----
From: simone.bortolaso at libero.it [mailto:simone.bortolaso at libero.it] 
Sent: Friday, January 21, 2005 9:56 AM
To: opencms-dev
Subject: [opencms-dev] how do i do a log user?

HI ALL I USE OPENCMS 5.01!

I BUILD ONE LOGIN FRONT END PAGE.

THE USER USUALLY LOG IN WITH NAME AND PASSWORD AND ENTER IN SPECIAL AREA
NETWORK.
THE USER MUST NAVIGATE IN HIS PROTECTED PAGES SITE.

I DO A JSP LOGIN <FORM> WITH TWO <INPUT> FIELDS AND USE
cms.loginUser(name,password); in JSP TEMPLATE.


THE PROBLEM IS:  HOW DO I PRESERVE IS LOGIN INFORMATION BETWEEN PAGES
NAVIGATION?
I TRY THE STANDARD WAY TO STORE ALL LOGIN INFORMATION  IN session OBJECT
BUT  
EACH TIMES THE SESSION IS NULL.


 
ANY IDEAS?









____________________________________________________________
6X velocizzare la tua navigazione a 56k? 6X Web Accelerator di Libero!
Scaricalo su INTERNET GRATIS 6X http://www.libero.it




_______________________________________________
This mail is send to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please
visit
http://mail.opencms.org/mailman/listinfo/opencms-dev




More information about the opencms-dev mailing list