diff --git a/apps/assets/tasks/gather_asset_users.py b/apps/assets/tasks/gather_asset_users.py index 7914c9720..5d8372451 100644 --- a/apps/assets/tasks/gather_asset_users.py +++ b/apps/assets/tasks/gather_asset_users.py @@ -92,7 +92,7 @@ def add_asset_users(assets, results): for username, data in users.items(): defaults = {'asset': asset, 'username': username, 'present': True} if data.get("ip"): - defaults["ip_last_login"] = data["ip"] + defaults["ip_last_login"] = data["ip"][:32] if data.get("date"): defaults["date_last_login"] = data["date"] GatheredUser.objects.update_or_create( diff --git a/apps/orgs/models.py b/apps/orgs/models.py index 5fb2d7ba6..274080fa4 100644 --- a/apps/orgs/models.py +++ b/apps/orgs/models.py @@ -230,8 +230,14 @@ def _none2list(*args): return ([] if v is None else v for v in args) -def _users2pks(users, admins, auditors): - return [user.pk for user in chain(users, admins, auditors) if hasattr(user, 'pk')] +def _users2pks_if_need(users, admins, auditors): + pks = [] + for user in chain(users, admins, auditors): + if hasattr(user, 'pk'): + pks.append(user.pk) + else: + pks.append(user) + return pks class UserRoleMapper(dict): @@ -271,7 +277,7 @@ class OrgMemeberManager(models.Manager): users, admins, auditors = _none2list(users, admins, auditors) send = partial(signals.m2m_changed.send, sender=self.model, instance=org, reverse=False, - model=User, pk_set=_users2pks(users, admins, auditors), using=self.db) + model=User, pk_set=_users2pks_if_need(users, admins, auditors), using=self.db) send(action="pre_remove") self.filter(org_id=org.id).filter( @@ -302,7 +308,7 @@ class OrgMemeberManager(models.Manager): oms_add.append(self.model(org_id=org.id, user_id=_user, role=_role)) send = partial(signals.m2m_changed.send, sender=self.model, instance=org, reverse=False, - model=User, pk_set=_users2pks(users, admins, auditors), using=self.db) + model=User, pk_set=_users2pks_if_need(users, admins, auditors), using=self.db) send(action='pre_add') self.bulk_create(oms_add, ignore_conflicts=True) diff --git a/apps/terminal/api/session.py b/apps/terminal/api/session.py index 16033b390..719d7af4f 100644 --- a/apps/terminal/api/session.py +++ b/apps/terminal/api/session.py @@ -155,7 +155,6 @@ class SessionReplayViewSet(AsyncApiMixin, viewsets.ViewSet): return data def is_need_async(self): - return False if self.action != 'retrieve': return False return True diff --git a/apps/users/api/profile.py b/apps/users/api/profile.py index b7ba0bbff..473ad3819 100644 --- a/apps/users/api/profile.py +++ b/apps/users/api/profile.py @@ -10,6 +10,7 @@ from common.permissions import ( ) from .. import serializers from ..models import User +from ..utils import send_reset_password_success_mail from .mixins import UserQuerysetMixin __all__ = [ @@ -85,3 +86,7 @@ class UserPublicKeyApi(generics.RetrieveUpdateAPIView): def get_object(self): return self.request.user + + def perform_update(self, serializer): + super().perform_update(serializer) + send_reset_password_success_mail(self.request, self.get_object()) diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 78961dfbf..57bec7f2b 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -61,7 +61,7 @@ pytz==2018.3 PyYAML==5.1 redis==3.2.0 requests==2.22.0 -jms-storage==0.0.31 +jms-storage==0.0.34 s3transfer==0.3.3 simplejson==3.13.2 six==1.11.0