๐Ÿ“ฆ bpasero / vscode-auth-page

๐Ÿ“„ index.html ยท 57 lines
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="utf-8" />
	<title>GitHub Authentication - Sign In</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" type="text/css" media="screen" href="auth.css" />
</head>

<body>
	<div class="container">
		<div class="content">
			<div class="icon-container">
				<img src="code-icon.svg" class="vscode-icon">
			</div>
			<h1 class="title">Launching <span class="app-name">Visual Studio Code</span></h1>
			<div class="message">
				<div class="success-message">
					<p class="subtitle">You will be redirected in a few moments.</p>
					<p class="detail">If nothing happens, <a href="#" id="fallback-link">open this link in your browser</a>.</p>
				</div>
				<div class="error-message">
					<p class="subtitle">An error occurred while signing in:</p>
					<div class="detail"></div>
				</div>
			</div>
		</div>
	</div>
	<script>
		const urlParams = new URLSearchParams(window.location.search);
		const appName = urlParams.get('app_name');
		// document.querySelectorAll('.app-name').forEach(e => e.innerText = appName);

		const error = urlParams.get('error');
		const redirectUri = urlParams.get('redirect_uri');
		if (error) {
			document.querySelector('.error-message > .detail').textContent = error;
			document.querySelector('body').classList.add('error');
		} else if (redirectUri) {
			// Set up the fallback link
			const fallbackLink = document.getElementById('fallback-link');
			if (fallbackLink) {
				fallbackLink.href = redirectUri;
			}

			// Redirect after a delay
			setTimeout(() => {
				window.location = redirectUri;
			}, 1000);
		}
	</script>
</body>

</html>