Javascript style
This commit is contained in:
parent
173f4d8a82
commit
03cbab37f4
@ -1,55 +1,52 @@
|
|||||||
function cas_login(cas_server_login, service, login_service, callback){
|
function cas_login(cas_server_login, service, login_service, callback){
|
||||||
url = cas_server_login + '?service=' + encodeURIComponent(service);
|
var url = cas_server_login + "?service=" + encodeURIComponent(service);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: "GET",
|
||||||
url:url,
|
url,
|
||||||
beforeSend: function (request) {
|
beforeSend(request) {
|
||||||
request.setRequestHeader("X-AJAX", "1");
|
request.setRequestHeader("X-AJAX", "1");
|
||||||
},
|
},
|
||||||
xhrFields: {
|
xhrFields: {
|
||||||
withCredentials: true
|
withCredentials: true
|
||||||
},
|
},
|
||||||
success: function(data, textStatus, request){
|
success(data, textStatus, request){
|
||||||
if(data.status == 'success'){
|
if(data.status === "success"){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: "GET",
|
||||||
url: data.url,
|
url: data.url,
|
||||||
xhrFields: {
|
xhrFields: {
|
||||||
withCredentials: true
|
withCredentials: true
|
||||||
},
|
},
|
||||||
success: callback,
|
success: callback,
|
||||||
error: function (request, textStatus, errorThrown) {},
|
error(request, textStatus, errorThrown) {},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if(data.detail == "login required"){
|
if(data.detail === "login required"){
|
||||||
window.location.href = cas_server_login + '?service=' + encodeURIComponent(login_service);
|
window.location.href = cas_server_login + "?service=" + encodeURIComponent(login_service);
|
||||||
} else {
|
} else {
|
||||||
alert('error: ' + data.messages[1].message);
|
alert("error: " + data.messages[1].message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function (request, textStatus, errorThrown) {},
|
error(request, textStatus, errorThrown) {},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function cas_logout(cas_server_logout){
|
function cas_logout(cas_server_logout){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: "GET",
|
||||||
url:cas_server_logout,
|
url: cas_server_logout,
|
||||||
beforeSend: function (request) {
|
beforeSend(request) {
|
||||||
request.setRequestHeader("X-AJAX", "1");
|
request.setRequestHeader("X-AJAX", "1");
|
||||||
},
|
},
|
||||||
xhrFields: {
|
xhrFields: {
|
||||||
withCredentials: true
|
withCredentials: true
|
||||||
},
|
},
|
||||||
error: function (request, textStatus, errorThrown) {},
|
error(request, textStatus, errorThrown) {},
|
||||||
success: function(data, textStatus, request){
|
success(data, textStatus, request){
|
||||||
if(data.status == 'error'){
|
if(data.status === "error"){
|
||||||
alert('error: ' + data.messages[1].message);
|
alert("error: " + data.messages[1].message);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user