|
89 | 89 | </style>
|
90 | 90 |
|
91 | 91 | <script>
|
92 |
| - function decodeUsername(encodedUsername) { |
93 |
| - return atob(encodedUsername); |
94 |
| - } |
95 |
| - |
96 | 92 | function encodeUsername(username) {
|
97 | 93 | return btoa(username);
|
98 | 94 | }
|
99 | 95 |
|
| 96 | + function decodeUsername(encodedUsername) { |
| 97 | + return atob(encodedUsername); |
| 98 | + } |
| 99 | + |
100 | 100 | window.onload = async function () {
|
101 | 101 | try {
|
102 | 102 | if (localStorage.getItem('loggedIn') === 'true') {
|
103 |
| - const usernameEncoded = localStorage.getItem('usernameEnc'); |
104 |
| - const username = decodeUsername(usernameEncoded); |
105 |
| - localStorage.setItem('username', username); |
| 103 | + const username = localStorage.getItem('username'); |
106 | 104 |
|
107 | 105 | document.getElementById('authSection').style.display = 'none';
|
108 | 106 | document.getElementById('loggedInContent').style.display = 'block';
|
|
132 | 130 | try {
|
133 | 131 | const res = await fetch(`https://auth-api.itinerary.eu.org/auth/verifyToken/${PC}`);
|
134 | 132 | const data = await res.json();
|
135 |
| - const username = btoa(data.username); |
| 133 | + const plainUsername = data.username; |
| 134 | + const encodedUsername = btoa(plainUsername); |
136 | 135 |
|
137 | 136 | // Ban check (example logic)
|
138 |
| - if (username === 'PUT THE FIRST BANNED USER HERE') { |
| 137 | + if (encodedUsername === 'PUT THE FIRST BANNED USER HERE') { |
139 | 138 | localStorage.removeItem('loggedIn');
|
140 | 139 | localStorage.removeItem('username');
|
141 | 140 | window.location.href = 'banscreen.html?reason=spam';
|
142 | 141 | return;
|
143 | 142 | }
|
144 | 143 |
|
145 |
| - localStorage.setItem('usernameEnc', data.username); // base64 |
146 |
| - localStorage.setItem('username', username); // plain text |
| 144 | + localStorage.setItem('usernameEnc', encodedUsername); // encoded version |
| 145 | + localStorage.setItem('username', plainUsername); // plain version |
147 | 146 | localStorage.setItem('loggedIn', 'true');
|
148 | 147 | window.location.href = 'index.html';
|
149 | 148 | } catch (err) {
|
|
164 | 163 | }, 2000);
|
165 | 164 | }
|
166 | 165 |
|
167 |
| - function registerApiAuth() { |
168 |
| - const messageBox = document.getElementById("apiMessage"); |
169 |
| - const redirectLocation = encodeURIComponent(window.location.href); |
170 |
| - const authUrl = `https://ubbload.netlify.app/login?redirect=${redirectLocation}`; |
171 |
| - |
172 |
| - messageBox.style.color = "green"; |
173 |
| - messageBox.textContent = "Redirecting to APIAuth login (ubbload)... Follow the steps there."; |
174 |
| - setTimeout(() => { |
175 |
| - window.location.href = authUrl; |
176 |
| - }, 2000); |
177 |
| - } |
178 |
| - |
179 | 166 | function logout() {
|
180 | 167 | localStorage.removeItem('loggedIn');
|
181 | 168 | localStorage.removeItem('username');
|
|
191 | 178 | }
|
192 | 179 |
|
193 | 180 | function devToken() {
|
194 |
| - const usernameEnc = localStorage.getItem('usernameEnc'); |
| 181 | + const username = localStorage.getItem('username'); |
195 | 182 | const devTokens = document.getElementById('devTokens');
|
196 | 183 |
|
197 |
| - if (usernameEnc && devTokens) { |
198 |
| - const joined = "Your dev token is: " + usernameEnc + " - Make sure to only share it with Coding Hut services and partners or else you can get hacked!"; |
| 184 | + if (username && devTokens) { |
| 185 | + const token = btoa(username); |
| 186 | + const joined = "Your dev token is: " + token + " - Make sure to only share it with Coding Hut services and partners or else you can get hacked!"; |
199 | 187 | devTokens.style.color = "green";
|
200 | 188 | devTokens.textContent = joined;
|
201 | 189 | }
|
|
0 commit comments