Spaces:
Running
Running
Update static/mult-agent-auth.html
Browse files- static/mult-agent-auth.html +30 -11
static/mult-agent-auth.html
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
-
<title>
|
7 |
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
|
8 |
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
|
9 |
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
@@ -156,7 +156,7 @@
|
|
156 |
</div>
|
157 |
<div class="user-info">
|
158 |
<div class="user-name">{{ userName }}</div>
|
159 |
-
<button class="logout-btn" @click="
|
160 |
</div>
|
161 |
</div>
|
162 |
|
@@ -234,13 +234,36 @@
|
|
234 |
localStorage.setItem('currentPage', url);
|
235 |
this.toggleSidebar();
|
236 |
},
|
237 |
-
async
|
|
|
|
|
|
|
|
|
238 |
try {
|
239 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
this.redirectToLogin();
|
241 |
} catch (error) {
|
242 |
-
console.error("
|
243 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
}
|
245 |
}
|
246 |
},
|
@@ -250,11 +273,7 @@
|
|
250 |
if (!session) {
|
251 |
this.redirectToLogin();
|
252 |
} else {
|
253 |
-
|
254 |
-
const user = await account.get();
|
255 |
-
console.log("User:", user);
|
256 |
-
this.userName = user.name;
|
257 |
-
await this.checkAllowlist(user.email);
|
258 |
}
|
259 |
}
|
260 |
});
|
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Multi Agent Research</title>
|
7 |
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
|
8 |
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
|
9 |
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
|
|
156 |
</div>
|
157 |
<div class="user-info">
|
158 |
<div class="user-name">{{ userName }}</div>
|
159 |
+
<button class="logout-btn" @click="handleLogout">Logout</button>
|
160 |
</div>
|
161 |
</div>
|
162 |
|
|
|
234 |
localStorage.setItem('currentPage', url);
|
235 |
this.toggleSidebar();
|
236 |
},
|
237 |
+
async handleLogout() {
|
238 |
+
const loadingElement = document.createElement('div');
|
239 |
+
loadingElement.textContent = 'Logging out...';
|
240 |
+
document.body.appendChild(loadingElement);
|
241 |
+
|
242 |
try {
|
243 |
+
const logoutPromise = account.deleteSession('current');
|
244 |
+
const timeoutPromise = new Promise((_, reject) =>
|
245 |
+
setTimeout(() => reject(new Error('Logout timed out')), 5000)
|
246 |
+
);
|
247 |
+
|
248 |
+
await Promise.race([logoutPromise, timeoutPromise]);
|
249 |
+
|
250 |
+
localStorage.clear();
|
251 |
this.redirectToLogin();
|
252 |
} catch (error) {
|
253 |
+
console.error("Logout failed:", error);
|
254 |
+
alert("Logout failed. Please try again.");
|
255 |
+
} finally {
|
256 |
+
document.body.removeChild(loadingElement);
|
257 |
+
}
|
258 |
+
},
|
259 |
+
async fetchProfileInfo() {
|
260 |
+
try {
|
261 |
+
const user = await account.get();
|
262 |
+
this.userName = user.name || 'User';
|
263 |
+
await this.checkAllowlist(user.email);
|
264 |
+
} catch (error) {
|
265 |
+
console.error("Error fetching profile info:", error);
|
266 |
+
this.error = 'Error loading profile information.';
|
267 |
}
|
268 |
}
|
269 |
},
|
|
|
273 |
if (!session) {
|
274 |
this.redirectToLogin();
|
275 |
} else {
|
276 |
+
await this.fetchProfileInfo();
|
|
|
|
|
|
|
|
|
277 |
}
|
278 |
}
|
279 |
});
|