mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-05 22:57:11 -04:00
Added auth flow.
This commit is contained in:
parent
aa627761e8
commit
66fc735253
6 changed files with 294 additions and 32 deletions
18
src/static/oidc/consent.html
Normal file
18
src/static/oidc/consent.html
Normal file
|
@ -0,0 +1,18 @@
|
|||
<!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>
|
53
src/static/oidc/login.html
Normal file
53
src/static/oidc/login.html
Normal file
|
@ -0,0 +1,53 @@
|
|||
<!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) {
|
||||
return response.json();
|
||||
}
|
||||
throw new Error('Network response was not ok.');
|
||||
}).then(data => {
|
||||
if (data.status === 'success') {
|
||||
window.location.href = data.redirect;
|
||||
} else {
|
||||
document.getElementById('error').innerText = "Error signing in";
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('There has been a problem with your fetch operation:', 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>
|
Loading…
Add table
Add a link
Reference in a new issue