lemonldap-ng/lemonldap-ng-portal/site/htdocs/static/common/js/sslChoice.js

54 lines
1.4 KiB
JavaScript
Raw Normal View History

2020-10-09 22:29:56 +02:00
// Generated by CoffeeScript 1.12.8
2019-02-01 23:22:11 +01:00
(function() {
var sendUrl, tryssl;
2019-02-01 23:22:11 +01:00
tryssl = function() {
var path;
2019-07-09 10:34:46 +02:00
path = window.location.pathname;
console.log('path -> ', path);
console.log('Call URL -> ', window.datas.sslHost);
$.ajax(window.datas.sslHost, {
2020-03-26 20:21:09 +01:00
dataType: 'json',
xhrFields: {
withCredentials: true
2019-02-01 23:22:11 +01:00
},
success: function(data) {
sendUrl(path);
2019-02-01 23:22:11 +01:00
return console.log('Success -> ', data);
},
2020-03-26 20:21:09 +01:00
error: function(result) {
if (result.status === 0) {
sendUrl(path);
}
if (result.responseJSON && 'error' in result.responseJSON && result.responseJSON.error === "9") {
sendUrl(path);
}
if (result.responseJSON && 'html' in result.responseJSON) {
$('#errormsg').html(result.responseJSON.html);
$(window).trigger('load');
}
return console.log('Error during AJAX SSL authentication', result);
2019-02-01 23:22:11 +01:00
}
});
return false;
2019-02-01 23:22:11 +01:00
};
sendUrl = function(path) {
var form_url;
form_url = $('#lformSSL').attr('action');
if (form_url.match(/^#$/)) {
form_url = path;
} else {
form_url = form_url + path;
}
console.log('form action URL -> ', form_url);
$('#lformSSL').attr('action', form_url);
return $('#lformSSL').submit();
};
2019-02-01 23:22:11 +01:00
$(document).ready(function() {
return $('.sslclick').on('click', tryssl);
});
}).call(this);