Skip to content

Commit 8db93d1

Browse files
authored
Reverted account page as partial fix of #64
1 parent fb824d5 commit 8db93d1

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

src/account.html

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,14 @@
134134
};
135135

136136
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');
149139

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';
150145
}
151146

152147
if (authSuccess === 'true') {
@@ -157,8 +152,8 @@
157152

158153
function registerScratchAuth() {
159154
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`;
162157

163158
messageBox.style.color = "green";
164159
messageBox.textContent = "Redirecting to ScratchAuth... Follow the steps there.";
@@ -180,7 +175,8 @@
180175
}
181176

182177
function logout() {
183-
localStorage.clear();
178+
localStorage.removeItem('loggedIn');
179+
localStorage.removeItem('username');
184180
window.location.href = 'account.html';
185181
}
186182

0 commit comments

Comments
 (0)