🗝
summary refs log tree commit diff
path: root/nginx/handoff.html
blob: f0124512f1e4576c171edde566ca84430a7f61d6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<!DOCTYPE html>
<html style="align-items: center; background-color: darkcyan; display: flex; height: 100%">
	<head>
		<title>Handoff</title>
		<script>
			(async () => {
				const response = await fetch("https://dissociate.mia.jetzt/handoff", { credentials: "include" });
				if (response.status == 200) {
					const data = await response.json();
					if (data.expiresIn < 300) {
						console.log("token expiring soon, reauthenticating");
						location = "https://dissociate.mia.jetzt/logout";
					}
					await fetch(`/.nginx/cookie?token=${data.token}&max_age=${data.expiresIn - 60}`);
					if (location.hash) {
						location = location.hash.slice(1);
					} else {
						location = "/";
					}
				} else {
					console.log("not authenticated, redirecting");
					location = "https://dissociate.mia.jetzt/login";
				}
			})()
		</script>
	</head>
	<body style="background-color: whitesmoke; color: black; filter: drop-shadow(0.5em 0.7em); margin: auto; padding: 1em">
		<p style="font-family: serif; font-size: large; margin: 0">Performing authenticated handoff</p>
	</body>
</html>