2024-04-18 16:31:23 +01:00
|
|
|
<html><head>
|
|
|
|
<title>Login - Burgernotes</title>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
|
|
|
<link rel="stylesheet" type="text/css" href="../static/css/style.css" media="">
|
|
|
|
<script src="../static/js/hash-wasm.js"></script>
|
|
|
|
<link rel="icon" href="../static/svg/favicon.svg">
|
|
|
|
<script>
|
|
|
|
if (window.location.href.endsWith('/index.html')) {
|
|
|
|
if (window.location.origin !== null) {
|
|
|
|
var currentUrl = window.location.href;
|
|
|
|
var newUrl = currentUrl.replace('/index.html', '');
|
|
|
|
window.location.href = newUrl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
2024-03-28 17:07:30 +00:00
|
|
|
</head>
|
|
|
|
|
2024-04-18 16:31:23 +01:00
|
|
|
<body>
|
|
|
|
<p class="credit">Image by perga (@pergagreen on discord)</p>
|
|
|
|
<img src="/static/img/background.jpg" class="background">
|
|
|
|
<div class="inoutdiv">
|
|
|
|
<h2 class="w300">Authorise Application</h2>
|
|
|
|
<p id="statusBox">Loading...</p>
|
|
|
|
<br>
|
|
|
|
<div style="display: flex;justify-content: center;">
|
|
|
|
<button onclick="oauth();" style="margin: 0;width: 100%;margin-right: 2.5px;">Allow</button>
|
|
|
|
<button onclick="window.location.replace('https://www.hectabit.org');" style="margin: 0;width: 100%;margin-left: 2.5px;">Deny</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<script>
|
2024-04-02 18:43:05 +01:00
|
|
|
if (localStorage.getItem("DONOTSHARE-secretkey") === null) {
|
2024-04-16 16:18:19 +01:00
|
|
|
window.location.replace("/login" + window.location.search)
|
2024-04-02 18:39:08 +01:00
|
|
|
document.body.innerHTML = "Redirecting..."
|
|
|
|
throw new Error();
|
|
|
|
}
|
|
|
|
|
2024-04-18 16:31:23 +01:00
|
|
|
document.addEventListener("DOMContentLoaded", function() {
|
2024-03-31 12:49:09 +01:00
|
|
|
const urlParams = new URLSearchParams(window.location.search);
|
2024-04-18 16:31:23 +01:00
|
|
|
var statusBox = document.getElementById("statusBox");
|
2024-03-28 17:07:30 +00:00
|
|
|
|
2024-03-29 11:02:22 +00:00
|
|
|
// Get URL parameters
|
2024-04-02 16:57:19 +01:00
|
|
|
if (urlParams.has('client_id')) {
|
|
|
|
var client_id = urlParams.get('client_id');
|
2024-04-18 16:31:23 +01:00
|
|
|
statusBox.textContent = "Would you like to allow " + client_id + " to access your user infomation?"
|
2024-04-02 16:57:19 +01:00
|
|
|
var redirect_uri = urlParams.get('redirect_uri');
|
|
|
|
var response_type = urlParams.get('response_type');
|
|
|
|
} else {
|
|
|
|
window.location.replace("/dashboard");
|
2024-04-17 10:38:46 +01:00
|
|
|
document.body.innerHTML = "Redirecting..."
|
|
|
|
throw new Error();
|
2024-04-02 16:57:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (urlParams.has('state')) {
|
|
|
|
var state = urlParams.get('state');
|
2024-04-18 13:03:05 +01:00
|
|
|
} else {
|
|
|
|
state = "none"
|
2024-04-02 16:57:19 +01:00
|
|
|
}
|
2024-03-31 12:49:09 +01:00
|
|
|
|
|
|
|
if (urlParams.has('code_challenge')) {
|
|
|
|
code = urlParams.get('code_challenge');
|
|
|
|
codemethod = urlParams.get('code_challenge_method');
|
|
|
|
} else {
|
|
|
|
code = "none"
|
|
|
|
codemethod = "none"
|
|
|
|
}
|
2024-03-28 17:07:30 +00:00
|
|
|
|
2024-03-29 11:02:22 +00:00
|
|
|
// Get DONOTSHARE-secretkey from localStorage
|
|
|
|
var secret_key = localStorage.getItem("DONOTSHARE-secretkey");
|
2024-04-18 13:03:05 +01:00
|
|
|
var now = new Date();
|
|
|
|
var expireTime = now.getTime() + (21 * 1000); // 21 seconds from now
|
|
|
|
var expires = new Date(expireTime).toUTCString();
|
2024-04-18 16:31:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function oauth() {
|
2024-04-18 13:21:36 +01:00
|
|
|
document.cookie = "key=" + secret_key + "; expires=" + expires + "; path=/";
|
2024-03-28 17:07:30 +00:00
|
|
|
|
2024-03-29 11:02:22 +00:00
|
|
|
// Send data to example.org using POST request
|
2024-04-18 13:19:57 +01:00
|
|
|
window.location.replace("/api/auth?client_id=" + client_id + "&redirect_uri=" + redirect_uri + "&code_challenge_method=" + codemethod + "&code_challenge=" + code + "&state=" + state)
|
2024-03-29 11:02:22 +00:00
|
|
|
}
|
2024-03-28 17:07:30 +00:00
|
|
|
</script>
|
2024-04-18 16:31:23 +01:00
|
|
|
</body></html>
|