* fix(xpack): 修复last login太长的问题 (#4786)

Co-authored-by: ibuler <ibuler@qq.com>

* perf: 更新密码中也发送邮件 (#4789)

Co-authored-by: ibuler <ibuler@qq.com>

* fix(terminal): 修复获取螺旋的异步api

* fix(terminal): 修复有的录像存储有问题的导致下载录像的bug

* fix(orgs): 修复组织添加用户bug

* perf(requirements): 修改jms-storage==0.0.34 (#4797)

Co-authored-by: Bai <bugatti_it@163.com>

Co-authored-by: fit2bot <68588906+fit2bot@users.noreply.github.com>
Co-authored-by: ibuler <ibuler@qq.com>
Co-authored-by: Bai <bugatti_it@163.com>
pull/4809/head
xinwen 2020-10-15 12:00:38 +08:00 committed by GitHub
parent 475c0e4187
commit e3dd03f4c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 7 deletions

View File

@ -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(

View File

@ -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)

View File

@ -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

View File

@ -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())

View File

@ -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