[opencms-dev] Login/Logout problem
A. Schirmacher
nn4l at yahoo.de
Mon Sep 29 20:44:02 CEST 2003
I have a problem with logout, please see source code
below. The effect is that logout "appears" to work,
however when the next page is loaded then the previous
logged in user is back. Very strange.
What is the reason? Is this a bug?
<%@ page session="true" %>
<%@ page
import="java.util.*,com.opencms.core.*,com.opencms.file.*,com.opencms.flex.jsp.*"
%>
<%@ taglib prefix="cms"
uri="http://www.opencms.org/taglib/cms" %>
<cms:include property="template" suffix=".jsp"
element="head" />
<%
CmsJspActionElement cms = new
CmsJspActionElement(pageContext, request, response);
CmsObject cmso = cms.getCmsObject();
String username =
request.getParameter("username");
String password =
request.getParameter("password");
String init = request.getParameter("init");
String logout = request.getParameter("logout");
String login = request.getParameter("login");
out.println("logged in as:" + cms.user("name") +
"<br>");
if ("init".equals(init)) {
cmso.addWebUser("User1", "test", "Users", "Web
Registration", new Hashtable(), cmso.C_FLAG_ENABLED);
cmso.addWebUser("User2", "test", "Users", "Web
Registration", new Hashtable(), cmso.C_FLAG_ENABLED);
cmso.addWebUser("User3", "test", "Users", "Web
Registration", new Hashtable(), cmso.C_FLAG_ENABLED);
} else if ("logout".equals(logout)) {
out.println("logging out<br>");
cmso.loginUser(cmso.anonymousUser().getName(),
"");
cms = new CmsJspActionElement(pageContext,
request, response);
out.println("current user now:" +
cms.user("name") + "<br>");
} else if ("login".equals(login)) {
try {
out.println("login with " + username + ",
password " + password + "<br>");
cmso.loginWebUser(username, password);
cms = new CmsJspActionElement(pageContext,
request, response);
out.println("current user now:" +
cms.user("name") + "<br>");
}
catch (Exception e) {
out.println("login failed<br>");
}
}
%>
<form method="POST">
<input type="submit" name="refresh" value="refresh">
<br>
<input type="submit" name="init" value="init">
<br>
<input type="submit" name="logout" value="logout">
<br>
<input type="text" name="username" value="">
<input type="text" name="password" value="">
<input type="submit" name="login" value="login">
<br>
</form>
<cms:include property="template" suffix=".jsp"
element="foot" />
__________________________________________________________________
Gesendet von Yahoo! Mail - http://mail.yahoo.de
Logos und Klingeltöne fürs Handy bei http://sms.yahoo.de
More information about the opencms-dev
mailing list