[opencms-dev] Login as Admin and "login back" as the previous user
karl adenener
adenener at hotmail.com
Tue Jan 15 16:21:31 CET 2008
Dear Célio.
I was searching long time for an good solution of this problem, I found only a bad workaround.
My solution
- normal login with cmso.loginUser ("name", password) and - do something ...
- CmsObject cmsoa = OpenCms.initCmsObject(OpenCms.getDefaultUsers().getUserGuest());
and login as an admin => cmsoa.loginUser("Admin", password);
- get the context =>getRequestContext().setSiteRoot(OpenCms.getSiteManager().getDefaultSite().getSiteRoot());
- get the right project
=>getRequestContext().setCurrentProject(cmsoa.readProject("Offline"));
- do something with admin rights
- login (or logout) as an guest, cmsoa.loginUser("Guest", password); and do not use this cmsoa-Object anymore.
- now you have only the original rights.
I am also interested in an more "nice" solution. I hope this is, what do you was looking for.
greetings
Aden
Date: Mon, 14 Jan 2008 23:48:39 -0300
From: celiofariajr at gmail.com
To: opencms-dev at opencms.org
Subject: [opencms-dev] Login as Admin and "login back" as the previous user
Hi all,
I am trying to programatically create a scheduled job and write some "acceptance" files (for the users to agree with the site Terms of Use). In order to do that, I have to login as Admin, because common users 1 - do not have the permission to schedule jobs and 2- cannot create files into the "acceptance" files directory (which is located inside my module).
The problem is, when I logout the Admin after do the writing and/or scheduling, the session is lost and the OpenCms current user is now "Guest" (or at least I think so).
I was wondering if there is an elegant way to log as Admin, do some tasks and "login back" as the previous user...
Another solution would be giving the users permission to schedule jobs, but the role that allows this also gives them other permissions I don´t want them to have.
Someone having the same problem? Any clues on other solutions?
TIA,
Célio.
_________________________________________________________________
Testen Sie Live.com - die schnelle, personalisierte Homepage, über die Sie auf alle für Sie relevanten Inhalte zentral zugreifen können.
http://www.live.com/getstarted
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20080115/4b244b73/attachment.htm>
More information about the opencms-dev
mailing list