31
31
}
32
32
</ style >
33
33
< script >
34
- async function registerUser ( ) {
34
+ function registerUser ( ) {
35
35
const username = document . getElementById ( "username" ) . value . trim ( ) ;
36
36
const messageBox = document . getElementById ( "message" ) ;
37
37
42
42
43
43
// Base64 encode the redirect URL where Scratch Auth will send the response
44
44
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` ;
45
48
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.` ;
48
52
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
70
57
}
71
58
</ script >
72
59
</ head >
@@ -81,10 +68,10 @@ <h2>Welcome! Please log in to continue.</h2>
81
68
< p id ="message " class ="message "> </ p >
82
69
< p >
83
70
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 .
85
72
</ p >
86
73
< 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 .
88
75
</ p >
89
76
</ div >
90
77
</ body >
0 commit comments