mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-11-04 14:49:58 +08:00
增加登录之后的重定向
This commit is contained in:
parent
190565da88
commit
da54a1245b
@ -1,4 +1,5 @@
|
||||
# coding=utf-8
|
||||
import urllib
|
||||
import functools
|
||||
from functools import wraps
|
||||
|
||||
@ -27,7 +28,7 @@ class BasePermissionDecorator(object):
|
||||
if self.request.is_ajax():
|
||||
return error_response(u"请先登录")
|
||||
else:
|
||||
return HttpResponseRedirect("/login/")
|
||||
return HttpResponseRedirect("/login/?__from=" + urllib.quote(self.request.build_absolute_uri()))
|
||||
|
||||
def check_permission(self):
|
||||
raise NotImplementedError()
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# coding=utf-8
|
||||
import urllib
|
||||
from functools import wraps
|
||||
|
||||
from django.http import HttpResponse, HttpResponseRedirect
|
||||
@ -30,7 +31,7 @@ def check_user_contest_permission(func):
|
||||
if request.is_ajax():
|
||||
return error_response(u"请先登录")
|
||||
else:
|
||||
return HttpResponseRedirect("/login/")
|
||||
return HttpResponseRedirect("/login/?__from=" + urllib.quote(request.build_absolute_uri()))
|
||||
|
||||
# kwargs 就包含了 url 里面的参数
|
||||
if "contest_id" in kwargs:
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
# coding=utf-8
|
||||
from django.conf.urls import include, url
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
|
||||
url(r'^login/$', TemplateView.as_view(template_name="oj/account/login.html"), name="user_login_page"),
|
||||
]
|
||||
@ -14,21 +14,18 @@ require(["jquery", "bsAlert", "csrfToken", "validator"], function ($, bsAlert, c
|
||||
method: "post",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
//成功登陆
|
||||
var ref = document.referrer;
|
||||
if (ref) {
|
||||
// 注册页和本页的来源的跳转回首页,防止死循环
|
||||
if (ref.indexOf("register") > -1 || ref.indexOf("login") > -1) {
|
||||
location.href = "/";
|
||||
return;
|
||||
}
|
||||
// 判断来源,只有同域下才跳转
|
||||
if (ref.split("/")[2].split(":")[0] == location.hostname) {
|
||||
location.href = ref;
|
||||
return;
|
||||
}
|
||||
function getLocationVal(id){
|
||||
var temp = unescape(location.search).split(id+"=")[1] || "";
|
||||
return temp.indexOf("&")>=0 ? temp.split("&")[0] : temp;
|
||||
}
|
||||
var from = getLocationVal("__from");
|
||||
if(from != ""){
|
||||
console.log(from);
|
||||
window.location.href = from;
|
||||
}
|
||||
else{
|
||||
location.href = "/";
|
||||
}
|
||||
location.href = "/";
|
||||
}
|
||||
else {
|
||||
refresh_captcha();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user