[opencms-dev] Getting current logged in user in online and offline project in a multi-site environment

Rüdiger Kurz r.kurz at alkacon.com
Tue Mar 19 10:41:20 CET 2013


created an issue on git for this:
https://github.com/alkacon/opencms-core/issues/157

Am 18.03.2013 22:25, schrieb Mathias Lin:
> 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

-- 
Kind Regards,
Rüdiger.

-------------------

Rüdiger Kurz

Alkacon Software GmbH  - The OpenCms Experts
http://www.alkacon.com - http://www.opencms.org



More information about the opencms-dev mailing list