Skip to content

Commit fb824d5

Browse files
authored
Update account.html
1 parent e378a39 commit fb824d5

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/account.html

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

136136
function checkAuth() {
137-
const authSuccess = new URLSearchParams(window.location.search).get('success');
138-
const username = new URLSearchParams(window.location.search).get('username');
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+
139149

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';
145150
}
146151

147152
if (authSuccess === 'true') {
@@ -152,8 +157,8 @@
152157

153158
function registerScratchAuth() {
154159
const messageBox = document.getElementById("scratchMessage");
155-
const redirectLocation = encodeURIComponent(window.location.href);
156-
const authUrl = `https://scratchauth-codinghut.onrender.com/auth`;
160+
const rLocation = btoa(window.location.href);
161+
const authUrl = `https://auth.itinerary.eu.org/auth?redirect=${location}&name=Scratch%20Coding%20Hut`;
157162

158163
messageBox.style.color = "green";
159164
messageBox.textContent = "Redirecting to ScratchAuth... Follow the steps there.";
@@ -175,8 +180,7 @@
175180
}
176181

177182
function logout() {
178-
localStorage.removeItem('loggedIn');
179-
localStorage.removeItem('username');
183+
localStorage.clear();
180184
window.location.href = 'account.html';
181185
}
182186

0 commit comments

Comments
 (0)