Skip to content

Commit 8033a2c

Browse files
authored
Update account.html
Scratch Auth customization
1 parent a368b8a commit 8033a2c

File tree

1 file changed

+13
-26
lines changed

1 file changed

+13
-26
lines changed

account.html

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
}
3232
</style>
3333
<script>
34-
async function registerUser() {
34+
function registerUser() {
3535
const username = document.getElementById("username").value.trim();
3636
const messageBox = document.getElementById("message");
3737

@@ -42,31 +42,18 @@
4242

4343
// Base64 encode the redirect URL where Scratch Auth will send the response
4444
const redirectLocation = btoa(window.location.href); // Redirect back to the current page after authentication
45+
46+
// Add specific parameters to the URL to prioritize the "Cloud data" method
47+
const authUrl = `https://auth.itinerary.eu.org/auth/?redirect=${redirectLocation}&name=Coding Hut&sign_in_method=cloud`;
4548

46-
// Request to get the token from Scratch Auth's backend
47-
const authUrl = `https://auth-api.itinerary.eu.org/auth/getTokens?redirect=${redirectLocation}&method=cloud&username=${username}`;
49+
// Display the instructions to the user
50+
messageBox.style.color = "green";
51+
messageBox.textContent = `Redirecting to Scratch Auth... Follow the steps there.`;
4852

49-
try {
50-
const response = await fetch(authUrl);
51-
const data = await response.json();
52-
53-
if (data.token) {
54-
// Display the message and redirect user to Scratch Auth
55-
messageBox.style.color = "green";
56-
messageBox.textContent = `Redirecting to Scratch Auth... Follow the steps there.`;
57-
58-
// Redirect to Scratch Auth after a brief delay
59-
setTimeout(() => {
60-
window.location.href = `https://auth.itinerary.eu.org/auth/?redirect=${redirectLocation}&token=${data.token}`;
61-
}, 2000); // Delay of 2 seconds before redirect
62-
} else {
63-
messageBox.style.color = "red";
64-
messageBox.textContent = "Authentication failed. Please try again.";
65-
}
66-
} catch (error) {
67-
messageBox.style.color = "red";
68-
messageBox.textContent = "Error connecting to the authentication service. Please try again later.";
69-
}
53+
// Redirect the user to Scratch Auth after a brief message
54+
setTimeout(() => {
55+
window.location.href = authUrl;
56+
}, 2000); // Delay the redirect for 2 seconds
7057
}
7158
</script>
7259
</head>
@@ -81,10 +68,10 @@ <h2>Welcome! Please log in to continue.</h2>
8168
<p id="message" class="message"></p>
8269
<p>
8370
Please note: You will be redirected to an external site (Scratch Auth) for authentication. Once there,
84-
follow the on-screen instructions to authenticate.
71+
choose the "Cloud Data" option for the quickest sign-in method.
8572
</p>
8673
<p>
87-
If you face issues, try changing your login method.
74+
If you are unable to use the "Cloud Data" option, other sign-in methods are available on Scratch Auth's page.
8875
</p>
8976
</div>
9077
</body>

0 commit comments

Comments
 (0)