2019-02-01 23:22:11 +01:00
|
|
|
# Launch SSL request
|
|
|
|
|
|
|
|
tryssl = () ->
|
2019-07-09 10:34:46 +02:00
|
|
|
path = window.location.pathname
|
2019-07-30 21:58:04 +02:00
|
|
|
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
|
|
|
# If request succeed, cookie is set, posting form to get redirection
|
|
|
|
# or menu
|
|
|
|
success: (data) ->
|
2019-07-30 21:58:04 +02:00
|
|
|
sendUrl path
|
2019-02-01 23:22:11 +01:00
|
|
|
console.log 'Success -> ', data
|
|
|
|
# Case else, will display PE_BADCREDENTIALS or fallback to next auth
|
|
|
|
# backend
|
2020-03-26 20:21:09 +01:00
|
|
|
error: (result) ->
|
|
|
|
# If the AJAX query didn't fire at all, it's probably
|
|
|
|
# a bad certificate
|
|
|
|
if result.status == 0
|
|
|
|
# We couldn't send the request.
|
|
|
|
# if client verification is optional, this means
|
|
|
|
# the certificate was rejected (or some network error)
|
|
|
|
sendUrl path
|
|
|
|
# For compatibility with earlier configs, handle PE9 by posting form
|
|
|
|
if result.responseJSON && 'error' of result.responseJSON && result.responseJSON.error == "9"
|
|
|
|
sendUrl path
|
|
|
|
|
|
|
|
# If the server sent a html error description, display it
|
|
|
|
if result.responseJSON && 'html' of result.responseJSON
|
|
|
|
$('#errormsg').html(result.responseJSON.html);
|
|
|
|
$(window).trigger('load');
|
|
|
|
console.log 'Error during AJAX SSL authentication', result
|
2019-06-27 16:40:56 +02:00
|
|
|
false
|
2019-07-10 17:15:40 +02:00
|
|
|
|
2019-07-30 21:58:04 +02:00
|
|
|
sendUrl = (path) ->
|
|
|
|
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)
|
|
|
|
$('#lformSSL').submit()
|
|
|
|
|
2019-02-01 23:22:11 +01:00
|
|
|
$(document).ready ->
|
2020-03-26 20:21:09 +01:00
|
|
|
$('.sslclick').on 'click', tryssl
|