[opencms-dev] Get user information during a listener execution
David Cortabarra Romero
david.cortabarra at sagasoluciones.com
Fri Oct 25 09:49:25 CEST 2024
Hello, thank you for your reply,
I have tried this solution before, however, when I do something like importing a module, the information I get about the user does not correspond to the one who is importing the module. The information I get is about the person who first created the resource and who last modified it. This is not the behaviour I want, as I want to know information about who interacts with the system.
Thanks, best regards,
David Cortabarra
De: DAVID RODRIGUEZ MERINO <david.rodriguez.merino at uva.es>
Enviado el: viernes, 25 de octubre de 2024 9:09
Para: The OpenCms mailing list <opencms-dev at opencms.org>
CC: David Cortabarra Romero <david.cortabarra at sagasoluciones.com>
Asunto: Re: [opencms-dev] Get user information during a listener execution
HI,
If you got the cmsobject and the resource path, you can use readResource to get CmsResource object (https://documentation.opencms.org/javadoc/core/org/opencms/file/CmsObject.html#readResource(java.lang.String)) and then get the user id with CmsResouce.getUserLastModified (https://documentation.opencms.org/javadoc/core/org/opencms/file/CmsResource.html#getUserLastModified())
To manage the session, you can use CmsSessionManager and get user sessions (https://documentation.opencms.org/javadoc/core/org/opencms/main/CmsSessionManager.html#getSessionInfos(org.opencms.util.CmsUUID)). You get some info (https://documentation.opencms.org/javadoc/core/org/opencms/main/CmsSessionInfo.html)
Salu2!!
--
David Rodríguez Merino
Área Web del Gabinete de Comunicación
Vicerrectorado de Comunicación
Universidad de Valladolid
Edificio Rector Tejerina
Plaza de Santa Cruz nº 6
47002 Valladolid
Email: david.rodriguez.merino at uva.es<mailto:david.rodriguez.merino at uva.es>
Email grupo: soporte-web at uva.es<mailto:soporte-web at uva.es>
De: opencms-dev <opencms-dev-bounces at opencms.org<mailto:opencms-dev-bounces at opencms.org>> en nombre de David Cortabarra Romero via opencms-dev <opencms-dev at opencms.org<mailto:opencms-dev at opencms.org>>
Fecha: viernes, 25 de octubre de 2024, 8:28
Para: opencms-dev at opencms.org<mailto:opencms-dev at opencms.org> <opencms-dev at opencms.org<mailto:opencms-dev at opencms.org>>
CC: David Cortabarra Romero <david.cortabarra at sagasoluciones.com<mailto:david.cortabarra at sagasoluciones.com>>
Asunto: [opencms-dev] Get user information during a listener execution
Hello,
I am working using OpenCms version 16.0. Trying to create a listener that acts when a modification or content creation event occurs, I need to get the user that performed the action.
I do not find this information available at any time during the listener execution because I only have access to the CmsObject and the resource I am acting on.
Inside the CmsObject I can get the context of the request, but the information of the user who has performed the action does not appear there, only the information of the user used to initialise the listener.
On the other hand, I have no way to obtain the session of the specific user who performed the action. I can get the session of all the users that are inside the system, but I have no way of knowing which one is related to the user that has performed the action. Finally, I also don't have access to the request made, where I could also get the information.
I would like to know if there is any way to get the information of the user who has performed the action during the execution of the listener.
Thanks,
Sincerely yours,
David Cortabarra
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20241025/cf3b0ede/attachment.htm>
More information about the opencms-dev
mailing list