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

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

* [Update] 优化切换组织时重定向页面逻辑 2
pull/3134/head
BaiJiangJie 2019-08-16 16:33:05 +08:00 committed by GitHub
parent 7d1e8d258c
commit 48826a9ad9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

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

View File

@ -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:
if referer.find(host) == -1:
return redirect(reverse('index'))
if UUID_PATTERN.search(referer):
return redirect(reverse('index'))
return redirect(referer)
else:
return redirect('index')
class SwitchToAOrgView(View):