Spaces:
Running
Running
Upload admin_users.html
Browse files
src/apps/templates/admin_users.html
CHANGED
|
@@ -109,10 +109,20 @@
|
|
| 109 |
<script>
|
| 110 |
async function fetchUsers() {
|
| 111 |
try {
|
| 112 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
if (!response.ok) {
|
| 114 |
if (response.status === 403 || response.status === 401) {
|
| 115 |
// For safety, immediately transfer unauthenticated users to the secure login portal
|
|
|
|
| 116 |
window.location.href = '/login?role=Admin';
|
| 117 |
return;
|
| 118 |
}
|
|
|
|
| 109 |
<script>
|
| 110 |
async function fetchUsers() {
|
| 111 |
try {
|
| 112 |
+
const token = localStorage.getItem('token');
|
| 113 |
+
if (!token) {
|
| 114 |
+
window.location.href = '/login?role=Admin';
|
| 115 |
+
return;
|
| 116 |
+
}
|
| 117 |
+
const response = await fetch('/api/admin/users', {
|
| 118 |
+
headers: {
|
| 119 |
+
'Authorization': `Bearer ${token}`
|
| 120 |
+
}
|
| 121 |
+
});
|
| 122 |
if (!response.ok) {
|
| 123 |
if (response.status === 403 || response.status === 401) {
|
| 124 |
// For safety, immediately transfer unauthenticated users to the secure login portal
|
| 125 |
+
localStorage.removeItem('token');
|
| 126 |
window.location.href = '/login?role=Admin';
|
| 127 |
return;
|
| 128 |
}
|