|
24 | 24 | color: red; |
25 | 25 | font-weight: bold; |
26 | 26 | } |
27 | | - input, button { |
| 27 | + button { |
28 | 28 | padding: 10px; |
29 | 29 | margin: 10px; |
30 | 30 | font-size: 16px; |
31 | 31 | } |
32 | 32 | </style> |
33 | 33 | <script> |
34 | 34 | function registerUser() { |
35 | | - const username = document.getElementById("username").value.trim(); |
36 | 35 | const messageBox = document.getElementById("message"); |
37 | 36 |
|
38 | | - if (!username) { |
39 | | - messageBox.textContent = "Please enter a Scratch username."; |
40 | | - return; |
41 | | - } |
42 | | - |
43 | 37 | const redirectLocation = encodeURIComponent(window.location.href); |
44 | 38 | const authUrl = `https://auth.itinerary.eu.org/auth/?redirect=${redirectLocation}&name=Coding%20Hut&sign_in_method=cloud`; |
45 | 39 |
|
|
50 | 44 | window.location.href = authUrl; |
51 | 45 | }, 2000); |
52 | 46 | } |
53 | | - // Simulate checking if the user is logged in |
54 | | - function checkAuth() { |
55 | | - const urlParams = new URLSearchParams(window.location.search); |
56 | | - const authSuccess = urlParams.get('success');// Example: Scratch Auth might return '?success=true' |
57 | | - const username = params.get('username'); |
58 | | - |
59 | | - if (authSuccess === 'true') { |
60 | | - // Redirect to index.html if login was successful |
61 | | - localStorage.setItem('loggedIn', 'true'); |
62 | | - window.location.href = 'index.html'; |
| 47 | + |
| 48 | + // Simulate checking if the user is logged in |
| 49 | + function checkAuth() { |
| 50 | + const urlParams = new URLSearchParams(window.location.search); |
| 51 | + const authSuccess = urlParams.get('success'); // Example: Scratch Auth might return '?success=true' |
| 52 | + |
| 53 | + if (authSuccess === 'true') { |
| 54 | + // Redirect to index.html if login was successful |
| 55 | + localStorage.setItem('loggedIn', 'true'); |
| 56 | + window.location.href = 'index.html'; |
| 57 | + } |
63 | 58 | } |
64 | | - } |
65 | 59 |
|
66 | | - // Run this check when the page loads |
67 | | - window.onload = checkAuth; |
| 60 | + // Run this check when the page loads |
| 61 | + window.onload = checkAuth; |
68 | 62 | </script> |
69 | 63 | </head> |
70 | 64 | <body> |
71 | 65 | <div class="header"><h1>Scratch Authentication</h1></div> |
72 | 66 | <div class="content"> |
73 | 67 | <h2>Welcome! Please log in to continue.</h2> |
74 | | - <label for="username">Scratch Username:</label> |
75 | | - <input type="text" id="username" placeholder="Enter your Scratch username" /> |
76 | | - <br /> |
77 | 68 | <button onclick="registerUser()">Register</button> |
78 | 69 | <p id="message" class="message"></p> |
79 | 70 | <p> |
|
0 commit comments