Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove token from html #8

Merged
merged 6 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions img/ls-login.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
313 changes: 242 additions & 71 deletions token.html
Original file line number Diff line number Diff line change
@@ -1,80 +1,212 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en-us">
<head>
<!-- Meta -->
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1" />

<head>
<title>Token</title>
<meta name="description" content="Local EGA in Norway" />

<!-- Meta -->
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<!-- The compiled CSS file -->
<link rel="stylesheet" href="css/production.css" />

<title>Token</title>
<meta name="description" content="Local EGA in Norway">
<!-- Web fonts -->
<link
href="https://fonts.googleapis.com/css?family=Montserrat:400,400i,700|Source+Serif+Pro:700"
rel="stylesheet"
/>

<!-- The compiled CSS file -->
<link rel="stylesheet" href="css/production.css">
<!-- favicon.ico. Place these in the root directory. -->
<link rel="shortcut icon" href="/img/favicon.ico" />

<!-- Web fonts -->
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,400i,700|Source+Serif+Pro:700" rel="stylesheet">

<!-- favicon.ico. Place these in the root directory. -->
<link rel="shortcut icon" href="/img/favicon.ico">

</head>

<body class="has-animations">
<style>
.btn:hover {
transform: translateY(-1px);
box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}
body {
background: #f9fafb;
}
</style>
</head>

<body class="has-animations">
<div class="container pt3 mt2 text--gray align--center">
<div class="grid-column align--left">
<a href="/" class="link"><img class="logo" style="max-height: 100px; vertical-align: -2em; margin: 20px;" src="/img/EGA_submarcas_Norway.svg" alt="Federated EGA Norway node"></a>
<a href="/docs.html" class="link link--text" style="margin: 8px;">Docs and Info</a>
<a href="/pp.html" class="link link--text" style="margin: 8px;">Privacy Policy</a>
<a href="/tos.html" class="link link--text" style="margin: 8px;">Terms of Service</a>
<a href="mailto:[email protected]" class="link link--text" style="margin: 8px;">Contact Us</a>
<a href="/about.html" class="link link--text" style="margin: 8px;">About</a>
</div>
<div class="grid-column align--left">
<a href="/" class="link"
><img
class="logo"
style="max-height: 100px; vertical-align: -2em; margin: 20px"
src="/img/EGA_submarcas_Norway.svg"
alt="Federated EGA Norway node"
/></a>
<a href="/docs.html" class="link link--text" style="margin: 8px"
>Docs and Info</a
>
<a href="/pp.html" class="link link--text" style="margin: 8px"
>Privacy Policy</a
>
<a href="/tos.html" class="link link--text" style="margin: 8px"
>Terms of Service</a
>
<a
href="mailto:[email protected]"
class="link link--text"
style="margin: 8px"
>Contact Us</a
>
<a href="/about.html" class="link link--text" style="margin: 8px"
>About</a
>
</div>
</div>

<!-- Header -->
<header class="align--center pt3">
<div class="container--lg border--bottom pb3">
<h1 class="mb2">Federated EGA Norway node</h1>
<h2 class="mt3">Token for: </h2>
<p class="text--primary-color bold" id="sub"></p>
</div>
<div class="container--lg">
<h1 class="mb2">Federated EGA Norway node</h1>
</div>
</header>

<main>
<!-- Token section -->
<img
src="/img/ls-login.svg"
alt="LS Login"
style="width: 100%; max-width: 400px; display: block; margin: 0 auto; padding: 50px 5px 0 5px;"
>
<div class="container mt4">
<div class="grid-row">
<div class="grid-column align--center">
<!-- Success state -->
<div
id="tokenInterface"
style="
display: flex;
flex-direction: column;
align-items: center;
gap: 1.5rem;
"
>
<!-- Username section -->
<div style="
background: #f3f4f6;
padding: 1.5rem;
border-radius: 8px;
width: 100%;
max-width: 600px;
">
<div style="margin-bottom: 1rem;">
<h2 style="font-size: 1.2rem; margin: 0; color: #374151;">Username</h2>
<p class="text--primary-color bold" id="sub" style="font-size: 1.2rem; margin: 0.5rem 0; word-break: break-all;"></p>
</div>
<button
class="btn copy-username"
style="
background: #465be5;
padding: 12px 24px;
transition: all 0.2s ease;
border: none;
color: white;
width: 100%;
"
>
Copy Username
</button>
</div>

<!-- Feature list -->
<div class="container mt2">
<code id="token" class="align--justify align--center-on-mobile text--gray" style="overflow-wrap: break-word; max-width: 100px">
</code>
<div class="grid-row pt1 mt1">
<div class="grid-column align--center align--center-on-mobile">
<button class="btn" data-clipboard-target="#token">
Copy to clipboard
</button>
<!-- Token section -->
<div style="
background: #f3f4f6;
padding: 1.5rem;
border-radius: 8px;
width: 100%;
max-width: 600px;
">
<div style="margin-bottom: 1rem;">
<h2 style="font-size: 1.2rem; margin: 0; color: #374151;">Access Token</h2>
<p style="font-size: 1.2rem; margin: 0.5rem 0; color: #6b7280;">
[Hidden for security - Click button below to copy]
</p>
</div>
<button
class="btn copy-token"
style="
background: #465be5;
padding: 12px 24px;
transition: all 0.2s ease;
border: none;
color: white;
width: 100%;
"
>
Copy Access Token
</button>
</div>

<p
id="copyStatus"
style="
display: none;
color: #10b981;
margin: 0;
font-size: 0.9rem;
"
>
Copied to clipboard!
</p>
</div>
</div>

<!-- Error state -->
<p
id="errorStatus"
style="
display: none;
color: #dc2626;
margin: 0;
font-size: 0.9rem;
"
>
Error retrieving token. Please try again later.
</p>
</div>
</div>
</div>
</main>

<!-- Footer -->
<footer class="pt1 pb3 align--center-on-mobile">
<div class="container">
<div class="grid-row">
<div class="grid-column mt2 align--left align--center-on-mobile">
<ul class="no-bullets list--inline">
<li class="mr1"><a href="mailto:[email protected]" class="text"><img class="icon" src="/img/mail.svg" alt="Contact">[email protected]</a></li>
</ul>
</div>
</div>
<div class="grid-column mt2 span-half">
<p class="small">Design by <a href="https://www.papayatemplates.com" class="link link--text">Papaya</a>. Illustrations from&nbsp;<a href="https://undraw.co/" class="link link--text">Undraw</a>.</p>
</div>
<div class="container">
<div class="grid-row">
<div class="grid-column mt2 align--left align--center-on-mobile">
<ul class="no-bullets list--inline">
<li class="mr1">
<a href="mailto:[email protected]" class="text"
><img
class="icon"
src="/img/mail.svg"
alt="Contact"
/>[email protected]</a
>
</li>
</ul>
</div>
</div>
<div class="grid-column mt2 span-half">
<p class="small">
Design by
<a href="https://www.papayatemplates.com" class="link link--text"
>Papaya</a
>. Illustrations from&nbsp;<a
href="https://undraw.co/"
class="link link--text"
>Undraw</a
>.
</p>
</div>
</div>
</footer>

<!-- Scroll reveal -->
Expand All @@ -84,29 +216,68 @@ <h2 class="mt3">Token for: </h2>
<script src="js/production.js"></script>

<!-- Cookies popup -->
<script type="text/javascript" id="cookieinfo" src="js/cookieinfo.min.js" data-moreinfo="/pp.html"></script>
<script
type="text/javascript"
id="cookieinfo"
src="js/cookieinfo.min.js"
data-moreinfo="/pp.html"
></script>

<!-- Copy to clipboard button -->
<script src="js/clipboard.min.js"></script>

<script type="text/javascript">
fetch('/token')
.then(response => response.text())
.then(responseText => {
const base64Url = responseText.split('.')[1];
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
const jsonPayload = decodeURIComponent(atob(base64).split('').map(function(c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
document.getElementById("sub").innerHTML = JSON.parse(jsonPayload)['sub'];
document.getElementById("token").innerHTML = responseText;
new ClipboardJS('.btn');
})
.catch(error => {
console.error('Fetch error:', error);
fetch("/token", {
headers: {
"Content-Type": "application/json",
},
})
.then((response) => {
if (!response.ok) {
throw new Error("Failed to fetch token");
}
return response.text();
})
.then((responseText) => {
const base64Url = responseText.split(".")[1];
const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
const jsonPayload = decodeURIComponent(
atob(base64)
.split("")
.map(function (c) {
return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
})
.join("")
);
const username = JSON.parse(jsonPayload)["sub"];
document.getElementById("sub").innerHTML = username;

// Copy username button
const clipboardUsername = new ClipboardJS('.copy-username', {
text: () => username
});

// Copy token button
const clipboardToken = new ClipboardJS('.copy-token', {
text: () => responseText
});

// Handle copy success
[clipboardUsername, clipboardToken].forEach(clipboard => {
clipboard.on("success", function (e) {
const copyStatus = document.getElementById("copyStatus");
copyStatus.style.display = "block";
setTimeout(() => {
copyStatus.style.display = "none";
}, 2000);
});
});
})
.catch((error) => {
console.error("Fetch error:", error);
document.getElementById("tokenInterface").style.display = "none";
document.getElementById("errorStatus").style.display = "block";
});
</script>

</body>
</body>
</html>