增加登录之后的重定向

This commit is contained in:
virusdefender
2015-10-20 20:07:35 +08:00
parent 190565da88
commit da54a1245b
5 changed files with 15 additions and 25 deletions

View File

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