Can now run as a Ory Hydra login and consent app
This commit is contained in:
33
resources/static/login/login.js
Normal file
33
resources/static/login/login.js
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
// Attempt to log in using ambient authority (e.g., Kerberos, SSL, etc)
|
||||
async function tryLoginAmbient() {
|
||||
let resp = await fetch("/login/krb5" + window.location.search, {method: "POST", redirect: "manual"})
|
||||
if (resp.ok) {
|
||||
window.location = await resp.text()
|
||||
}
|
||||
}
|
||||
|
||||
async function tryLoginPassword() {
|
||||
let userField = document.getElementById("user")
|
||||
let passwordField = document.getElementById("password")
|
||||
let doit = document.getElementById("doit")
|
||||
try {
|
||||
userField.enabled = passwordField.enabled = doit.enabled = false
|
||||
let resp = await fetch("/login/password" + window.location.search, {method: "POST"})
|
||||
if (resp.ok) {
|
||||
window.location = await resp.text()
|
||||
}
|
||||
} catch (e) {
|
||||
userField.enabled = passwordField.enabled = doit.enabled = true
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
tryLoginAmbient() // don't bother awaiting, just let 'er go
|
||||
document.addEventListener("load", () => {
|
||||
document.getElementById("doit").form.addEventListener("submit", function (e) {
|
||||
e.preventDefault()
|
||||
tryLoginPassword()
|
||||
return false
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user