[opencms-dev] Getting current logged in user in online and offline project in a multi-site environment
Mathias Lin
mail at mathiaslin.com
Mon Mar 18 22:25:13 CET 2013
I found the following problem and wondering how to best to solve it in a
multi-site environment:
I want to show the currently logged in user as follows:
Let's say I'm logged in to the OpenCms workplace as 'Admin' user, then the
following line
cmsObject.getGroupsOfUser(cmsObject.getRequestContext().currentUser().getName()
should output "Admin".
This works fine in BOTH online and offline project under the condition that
the workplace hostname and the site hostname is identical.
Such as it is the case with hostname1/siteA in the site configuration below.
<sites>
<workplace-server>http://hostname1:8080</workplace-server>
<default-uri>/sites/siteA/</default-uri>
<site server="http://hostname1:8080" uri="/sites/siteA/"/>
<site server="http://hostname2:8080" uri="/sites/siteB/"/>
</sites>
However, it does NOT work in BOTH offline and online project for
hostname2/siteB: when in the offline project, I am correctly getting
'Admin" as the logged in user, but when I switch to online project, the
current user is identified as 'Guest'.
Therefore I am wondering how it's possible to test offline and online
project with user related data in a multi-site configuration as above - in
my example for hostname2 / siteB.
I can only assign one hostname for the workplace server, and using the IP
address also doesn't work.
Would the only possible way be to provide a custom login form in the site
frontend under the site folder somewhere? As the workplace login seems to
have no meaning for sites which hostnames don't match the workplace
hostname.
Thanks,
Mathias
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20130318/8d21e654/attachment.htm>
More information about the opencms-dev
mailing list