oauth2-code-displayer/index.html
2024-04-14 13:19:52 +02:00

91 lines
3.4 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title id="title">Zionetrix - Authentication</title>
<link rel="stylesheet" href="style.css" />
<link rel="icon" href="logo.svg" sizes="32x32" />
<link rel="icon" href="logo.svg" sizes="192x192" />
<link rel="apple-touch-icon" href="logo.svg" />
<meta name="msapplication-TileImage" content="logo.svg" />
<style>
body {
margin: 0;
padding: 0;
display: grid;
place-content: center;
min-height: 100vh;
text-align: center;
font-family: Public Sans, sans-serif;
font-size: 100%;
color: #888;
line-height: 1.8;
}
#logo {
max-width: min(50vw, 20em);
}
input {
height: 1.1em;
font-family: Public Sans, sans-serif;
border: 1px solid #e88884;
font-size: 0.9em;
text-align: center;
width: min(50vw, 36em);
color: #888;
}
#error {
color: #e88884;
}
</style>
</head>
<body>
<div>
<img id="logo" src="logo.svg"></img>
<div id="confirm" style="display: none">
<p id="copy_paste">Please copy/paste the following code in your terminal:</p>
<input id="code" readonly="readonly" />
<p id="can_close">After copied this code, you could close this page.</p>
</div>
<div id="error" style="display: none">
<strong>Error:</strong> No authentication code found in URL.
</div>
</div>
<script>
const translations = {
fr: {
title: "Zionetrix - Authentification",
copy_paste: "Merci de copier/coller le code suivant dans votre terminal :",
can_close: "Une fois le code copier, vous pouvez fermer cette page.",
error: "<strong>Erreur :</strong> Aucun code d'authentification trouvé dans l'URL."
},
};
if (
navigator.languages
&& !navigator.languages[0].startsWith('en')
&& navigator.languages[0].substr(0, 2) in translations
) {
for (
const [id, text] of Object.entries(
translations[navigator.languages[0].substr(0, 2)]
)
) {
if (id == 'title')
document.title = text;
else
document.getElementById(id).innerHTML = text;
}
}
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.get('code')) {
document.getElementById("code").value = urlParams.get('code');
document.getElementById("confirm").style.display = "block";
}
else {
document.getElementById("error").style.display = "block";
}
</script>
</body>
</html>