Can now run as a Ory Hydra login and consent app

This commit is contained in:
2023-11-03 18:18:25 +01:00
parent 6498a8bd06
commit 805bfe56db
9 changed files with 226 additions and 5 deletions

View 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
})
})