lemonldap-ng/lemonldap-ng-portal/site/coffee/ssl.coffee
2019-07-09 10:40:52 +02:00

29 lines
670 B
CoffeeScript

# Launch SSL request
tryssl = () ->
host = window.datas.sslHost
path = window.location.pathname
url = "#{host}#{path}"
console.log 'Call URL -> ', url
$.ajax url,
dataType: 'jsonp'
# PE_BADCREDENTIALS
statusCode:
401: () ->
$('#lform').submit()
console.log 'Error code 401'
# If request succeed, cookie is set, posting form to get redirection
# or menu
success: (data) ->
$('#lform').submit()
console.log 'Success -> ', data
# Case else, will display PE_BADCREDENTIALS or fallback to next auth
# backend
error: () ->
$('#lform').submit()
console.log 'Error'
false
$(document).ready ->
$('.sslclick').on 'click', tryssl