Added Grunt to support asset pipelines and pre-processors; added SASS, Twig, and CoffeeScript to create the app
This commit is contained in:
3
assets/coffee/index.coffee
Normal file
3
assets/coffee/index.coffee
Normal file
@ -0,0 +1,3 @@
|
||||
window.onload = ->
|
||||
document.getElementById('ldapHost').textContent = localStorage.getItem('ldap_hostname')
|
||||
return
|
23
assets/coffee/login.coffee
Normal file
23
assets/coffee/login.coffee
Normal file
@ -0,0 +1,23 @@
|
||||
ldap = require('ldapjs')
|
||||
|
||||
loginForm = (event) ->
|
||||
event.preventDefault()
|
||||
bindHost = document.forms.loginForm.ldap_host.value
|
||||
bindDn = document.forms.loginForm.bind_dn.value
|
||||
bindPw = document.forms.loginForm.bind_pw.value
|
||||
client = ldap.createClient(url: 'ldap://' + bindHost + '/')
|
||||
client.bind bindDn, bindPw, (err) ->
|
||||
if err
|
||||
document.querySelector('h1').textContent = 'error'
|
||||
else
|
||||
document.querySelector('h1').textContent = 'Logged in!'
|
||||
localStorage.setItem('ldap_hostname', document.forms.loginForm.ldap_host.value)
|
||||
localStorage.setItem('ldap_bind_dn', document.forms.loginForm.bind_dn.value)
|
||||
localStorage.setItem('ldap_bind_pw', document.forms.loginForm.bind_pw.value)
|
||||
window.location.href = 'index.html'
|
||||
return
|
||||
return
|
||||
|
||||
window.onload = ->
|
||||
document.getElementById('loginForm').addEventListener 'submit', loginForm
|
||||
return
|
Reference in New Issue
Block a user