[opencms-dev] Login from Struts2 Action
Thomas Göttlich
guo.tuomi at googlemail.com
Fri Apr 30 09:03:49 CEST 2010
Hi,
we're using Struts 2 within OpenCMS and want to login our users into OpenCMS
via an action.
Login seems to work but is not persisted (no OpenCMS session is created).
Here's the relevant part of the login action:
CmsObject tInitCmsObject = OpenCms.initCmsObject(
OpenCms.getDefaultUsers().getUserGuest() );
if( tInitCmsObject != null )
{
String tLoggedInUserName;
tLoggedInUserName = tInitCmsObject.loginUser( username, password );
System.out.println( "Logged in user " + tLoggedInUserName );
if(tInitCmsObject.getRequestContext().currentUser().isGuestUser())
{
System.out.println("Login failed - still guest user");
}
HttpSession tSession = ServletActionContext.getRequest().getSession(
true );
if (project != null)
{
// if this fails, the login is regarded as a failure as well
CmsProject tProject = tInitCmsObject.readProject(project);
tInitCmsObject.getRequestContext().setCurrentProject(tProject);
tInitCmsObject.getRequestContext().setSiteRoot( siteRoot );
}
}
The output (only the line "Logged in user ..." is printed) suggests that
login succeeded.
However, if I now want to access a secured page (the permissions are set
correctly) it doesn't work.
Checking for sessions in the session manager reveals that there's no
session.
Any ideas?
Thanks in advance,
Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20100430/cf82b348/attachment.htm>
More information about the opencms-dev
mailing list