Unverified Commit 48826a9a authored by BaiJiangJie's avatar BaiJiangJie Committed by GitHub

[Update] 优化切换组织时重定向页面逻辑 (#3133)

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

* [Update] 优化切换组织时重定向页面逻辑 2
parent 7d1e8d25
......@@ -12,7 +12,7 @@ import copy
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
......
......@@ -4,6 +4,7 @@ from django.http import HttpResponseForbidden
from django.views.generic import DetailView, View
from .models import Organization
from common.utils import UUID_PATTERN
class SwitchOrgView(DetailView):
......@@ -17,10 +18,11 @@ class SwitchOrgView(DetailView):
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):
......
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