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,
|
2019-02-07 19:27:42 +01:00
|
|
|
dataType: 'jsonp'
|
2019-02-01 23:22:11 +01:00
|
|
|
# PE_BADCREDENTIALS
|
|
|
|
statusCode:
|
|
|
|
401: () ->
|
|
|
|
$('#lformSSL').submit()
|
|
|
|
console.log 'Error code 401'
|
|
|
|
# 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
|
|
|
|
error: () ->
|
2019-07-30 21:58:04 +02:00
|
|
|
sendUrl path
|
2019-02-01 23:22:11 +01:00
|
|
|
console.log 'Error'
|
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 ->
|
2019-07-30 21:58:04 +02:00
|
|
|
$('.sslclick').on 'click', tryssl
|