Properly reset security context on activity reactivation

The cold to reactivate an activity could sometimes switch to 'Anonymous User' and not switch back.

Move the user switching logic to inside the 'try' block that restores the user afterwards.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30778 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent eb81fb79
...@@ -276,10 +276,10 @@ class Message: ...@@ -276,10 +276,10 @@ class Message:
else: else:
try: try:
old_security_manager = getSecurityManager() old_security_manager = getSecurityManager()
# Change user if required (TO BE DONE)
# We will change the user only in order to execute this method
user = self.changeUser(self.user_name, activity_tool)
try: try:
# Change user if required (TO BE DONE)
# We will change the user only in order to execute this method
self.changeUser(self.user_name, activity_tool)
try: try:
# XXX: There is no check to see if user is allowed to access # XXX: There is no check to see if user is allowed to access
# that method ! # that method !
...@@ -351,17 +351,16 @@ Exception: %s %s ...@@ -351,17 +351,16 @@ Exception: %s %s
def reactivate(self, activity_tool, activity=DEFAULT_ACTIVITY): def reactivate(self, activity_tool, activity=DEFAULT_ACTIVITY):
# Reactivate the original object. # Reactivate the original object.
obj= self.getObject(activity_tool) obj= self.getObject(activity_tool)
# Change user if required (TO BE DONE) old_security_manager = getSecurityManager()
# We will change the user only in order to execute this method
current_user = str(_getAuthenticatedUser(self))
user = self.changeUser(self.user_name, activity_tool)
try: try:
# Change user if required (TO BE DONE)
# We will change the user only in order to execute this method
user = self.changeUser(self.user_name, activity_tool)
active_obj = obj.activate(activity=activity, **self.activity_kw) active_obj = obj.activate(activity=activity, **self.activity_kw)
getattr(active_obj, self.method_id)(*self.args, **self.kw) getattr(active_obj, self.method_id)(*self.args, **self.kw)
finally: finally:
# Use again the previous user # Use again the previous user
if user is not None: setSecurityManager(old_security_manager)
self.changeUser(current_user, activity_tool)
def setExecutionState(self, is_executed, exc_info=None, log=True, context=None): def setExecutionState(self, is_executed, exc_info=None, log=True, context=None):
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment