|
134 | 134 | };
|
135 | 135 |
|
136 | 136 | function checkAuth() {
|
137 |
| - const PC = new URLSearchParams(window.location.search).get('privateCode'); |
138 |
| - |
139 |
| - if (PC) { |
140 |
| - const res = await fetch(`https://auth-api.itinerary.eu.org/auth/verifyToken/${PC}`); |
141 |
| - const data = await response.json(); |
142 |
| - const username = data.username; |
143 |
| - localStorage.setItem('username', username); |
144 |
| - localStorage.setItem('usernameEnc', btoa(username)); |
145 |
| - localStorage.setItem('loggedIn', 'true') |
146 |
| - |
147 |
| - |
148 |
| - |
| 137 | + const authSuccess = new URLSearchParams(window.location.search).get('success'); |
| 138 | + const username = new URLSearchParams(window.location.search).get('username'); |
149 | 139 |
|
| 140 | + if (username) { |
| 141 | + const decodedUsername = decodeUsername(username); // Decode the username using atob |
| 142 | + localStorage.setItem('usernameEnc', username); // Store the original Base64-encoded username |
| 143 | + localStorage.setItem('loggedIn', 'true'); |
| 144 | + window.location.href = 'index.html'; |
150 | 145 | }
|
151 | 146 |
|
152 | 147 | if (authSuccess === 'true') {
|
|
157 | 152 |
|
158 | 153 | function registerScratchAuth() {
|
159 | 154 | const messageBox = document.getElementById("scratchMessage");
|
160 |
| - const rLocation = btoa(window.location.href); |
161 |
| - const authUrl = `https://auth.itinerary.eu.org/auth?redirect=${location}&name=Scratch%20Coding%20Hut`; |
| 155 | + const redirectLocation = encodeURIComponent(window.location.href); |
| 156 | + const authUrl = `https://scratchauth-codinghut.onrender.com/auth`; |
162 | 157 |
|
163 | 158 | messageBox.style.color = "green";
|
164 | 159 | messageBox.textContent = "Redirecting to ScratchAuth... Follow the steps there.";
|
|
180 | 175 | }
|
181 | 176 |
|
182 | 177 | function logout() {
|
183 |
| - localStorage.clear(); |
| 178 | + localStorage.removeItem('loggedIn'); |
| 179 | + localStorage.removeItem('username'); |
184 | 180 | window.location.href = 'account.html';
|
185 | 181 | }
|
186 | 182 |
|
|
0 commit comments