##// END OF EJS Templates
users: fetch user data for user removal hook, *before* actually marking object for deletion.
marcink -
r3979:a1866b8a default
parent child Browse files
Show More
@@ -507,6 +507,8 b' class UserModel(BaseModel):'
507
507
508 def delete(self, user, cur_user=None, handle_repos=None,
508 def delete(self, user, cur_user=None, handle_repos=None,
509 handle_repo_groups=None, handle_user_groups=None):
509 handle_repo_groups=None, handle_user_groups=None):
510 from rhodecode.lib.hooks_base import log_delete_user
511
510 if not cur_user:
512 if not cur_user:
511 cur_user = getattr(
513 cur_user = getattr(
512 get_current_rhodecode_user(), 'username', None)
514 get_current_rhodecode_user(), 'username', None)
@@ -547,12 +549,14 b' class UserModel(BaseModel):'
547 u'removed. Switch owners or remove those user groups:%s'
549 u'removed. Switch owners or remove those user groups:%s'
548 % (user.username, len(user_groups), ', '.join(user_groups)))
550 % (user.username, len(user_groups), ', '.join(user_groups)))
549
551
552 user_data = user.get_dict() # fetch user data before expire
553
550 # we might change the user data with detach/delete, make sure
554 # we might change the user data with detach/delete, make sure
551 # the object is marked as expired before actually deleting !
555 # the object is marked as expired before actually deleting !
552 self.sa.expire(user)
556 self.sa.expire(user)
553 self.sa.delete(user)
557 self.sa.delete(user)
554 from rhodecode.lib.hooks_base import log_delete_user
558
555 log_delete_user(deleted_by=cur_user, **user.get_dict())
559 log_delete_user(deleted_by=cur_user, **user_data)
556 except Exception:
560 except Exception:
557 log.error(traceback.format_exc())
561 log.error(traceback.format_exc())
558 raise
562 raise
General Comments 0
You need to be logged in to leave comments. Login now