Added working oauth2.

This commit is contained in:
SamTV12345 2024-03-25 15:34:37 +01:00
parent 04e4a5eee0
commit c966e12926
19 changed files with 401 additions and 198 deletions

View file

@ -1,18 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Consent</title>
<script>
window.onload = ()=>{
const form = document.getElementsByTagName('form')[0]
form.action = '/interaction/' + new URLSearchParams(window.location.search).get('state')
}
</script>
</head>
<body>
<form action="" autocomplete="off" method="post">
<input type="hidden" name="prompt" value="consent"/>
<button autofocus type="submit" class="login login-submit">Continue</button>
</form>
</body>

View file

@ -1,50 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
function login() {
const form = document.querySelector('form');
form.addEventListener('submit', function (event) {
event.preventDefault();
const formData = new FormData(form);
const data = {};
formData.forEach((value, key) => {
data[key] = value;
});
const sessionId = new URLSearchParams(window.location.search).get('state');
fetch('/interaction/'+sessionId, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
redirect: 'follow',
body: JSON.stringify(data),
}).then(response => {
if (response.ok) {
if (response.redirected) {
window.location.href = response.url;
}
} else {
document.getElementById('error').innerText = "Error signing in";
}
}).catch(error => {
document.getElementById('error').innerText = "Error signing in"+error;
});
});
}
window.onload = login;
</script>
<form autocomplete="off" method="post">
<input type="hidden" name="prompt" value="login"/>
<input required type="text" name="login" placeholder="Enter any login"/>
<input required type="password" name="password" placeholder="and password"/>
<button type="submit" class="login login-submit">Sign-in</button>
<div id="error"></div>
</form>
</body>
</html>