Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* [Update] 优化切换组织时重定向页面逻辑 (jumpserver#3133)

* [Update] 优化切换组织时重定向页面逻辑

* [Update] 优化切换组织时重定向页面逻辑 2

* [Update] WebTerminal 跳转添加时间戳

* [Update] 修复创建授权规则授权节点时,系统用户不自动推送的问题
  • Loading branch information
BaiJiangJie authored Aug 26, 2019
1 parent 7d4e9c5 commit 0581867
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
20 changes: 10 additions & 10 deletions apps/assets/signals_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ def on_system_user_update(sender, instance=None, created=True, **kwargs):
push_system_user_to_assets.delay(instance, assets)


# @receiver(m2m_changed, sender=SystemUser.nodes.through)
# def on_system_user_nodes_change(sender, instance=None, **kwargs):
# if instance and kwargs["action"] == "post_add":
# logger.info("System user `{}` nodes update signal received".format(instance))
# assets = set()
# nodes = kwargs['model'].objects.filter(pk__in=kwargs['pk_set'])
# for node in nodes:
# assets.update(set(node.get_all_assets()))
# instance.assets.add(*tuple(assets))
#
@receiver(m2m_changed, sender=SystemUser.nodes.through)
def on_system_user_nodes_change(sender, instance=None, **kwargs):
if instance and kwargs["action"] == "post_add":
logger.info("System user `{}` nodes update signal received".format(instance))
assets = set()
nodes = kwargs['model'].objects.filter(pk__in=kwargs['pk_set'])
for node in nodes:
assets.update(set(node.get_all_assets()))
instance.assets.add(*tuple(assets))


@receiver(m2m_changed, sender=SystemUser.assets.through)
def on_system_user_assets_change(sender, instance=None, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion apps/common/utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import ipaddress


UUID_PATTERN = re.compile(r'[0-9a-zA-Z\-]{36}')
UUID_PATTERN = re.compile(r'\w{8}(-\w{4}){3}-\w{12}')
ipip_db = None


Expand Down
10 changes: 6 additions & 4 deletions apps/orgs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.views.generic import DetailView, View

from .models import Organization
from common.utils import UUID_PATTERN


class SwitchOrgView(DetailView):
Expand All @@ -17,10 +18,11 @@ def get(self, request, *args, **kwargs):
request.session['oid'] = oid
host = request.get_host()
referer = request.META.get('HTTP_REFERER')
if referer.find(host) != -1:
return redirect(referer)
else:
return redirect('index')
if referer.find(host) == -1:
return redirect(reverse('index'))
if UUID_PATTERN.search(referer):
return redirect(reverse('index'))
return redirect(referer)


class SwitchToAOrgView(View):
Expand Down
4 changes: 3 additions & 1 deletion apps/terminal/views/terminal.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# ~*~ coding: utf-8 ~*~
#
import time
from django.views.generic import ListView, UpdateView, DeleteView, \
DetailView, View
from django.utils.translation import ugettext as _
Expand Down Expand Up @@ -128,7 +129,8 @@ def get_context_data(self, **kwargs):

class WebTerminalView(View):
def get(self, request, *args, **kwargs):
return redirect('/luna/?' + request.GET.urlencode())
redirect_url = '/luna/?_={}&'.format(int(time.time()))
return redirect(redirect_url + request.GET.urlencode())


class WebSFTPView(View):
Expand Down

0 comments on commit 0581867

Please sign in to comment.