Vishwanath77 commited on
Commit
76f689b
·
verified ·
1 Parent(s): 7e698ac

Upload admin_users.html

Browse files
Files changed (1) hide show
  1. src/apps/templates/admin_users.html +11 -1
src/apps/templates/admin_users.html CHANGED
@@ -109,10 +109,20 @@
109
  <script>
110
  async function fetchUsers() {
111
  try {
112
- const response = await fetch('/api/admin/users');
 
 
 
 
 
 
 
 
 
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
  }