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){
|
||||
url = cas_server_login + '?service=' + encodeURIComponent(service);
|
||||
var url = cas_server_login + "?service=" + encodeURIComponent(service);
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url:url,
|
||||
beforeSend: function (request) {
|
||||
type: "GET",
|
||||
url,
|
||||
beforeSend(request) {
|
||||
request.setRequestHeader("X-AJAX", "1");
|
||||
},
|
||||
xhrFields: {
|
||||
withCredentials: true
|
||||
},
|
||||
success: function(data, textStatus, request){
|
||||
if(data.status == 'success'){
|
||||
success(data, textStatus, request){
|
||||
if(data.status === "success"){
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
type: "GET",
|
||||
url: data.url,
|
||||
xhrFields: {
|
||||
withCredentials: true
|
||||
},
|
||||
success: callback,
|
||||
error: function (request, textStatus, errorThrown) {},
|
||||
error(request, textStatus, errorThrown) {},
|
||||
});
|
||||
} else {
|
||||
if(data.detail == "login required"){
|
||||
window.location.href = cas_server_login + '?service=' + encodeURIComponent(login_service);
|
||||
if(data.detail === "login required"){
|
||||
window.location.href = cas_server_login + "?service=" + encodeURIComponent(login_service);
|
||||
} 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){
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url:cas_server_logout,
|
||||
beforeSend: function (request) {
|
||||
type: "GET",
|
||||
url: cas_server_logout,
|
||||
beforeSend(request) {
|
||||
request.setRequestHeader("X-AJAX", "1");
|
||||
},
|
||||
xhrFields: {
|
||||
withCredentials: true
|
||||
},
|
||||
error: function (request, textStatus, errorThrown) {},
|
||||
success: function(data, textStatus, request){
|
||||
if(data.status == 'error'){
|
||||
alert('error: ' + data.messages[1].message);
|
||||
error(request, textStatus, errorThrown) {},
|
||||
success(data, textStatus, request){
|
||||
if(data.status === "error"){
|
||||
alert("error: " + data.messages[1].message);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user