|
99 | 99 | <div class="user-actions"> |
100 | 100 | <div class="role-controls"> |
101 | 101 | <label for="role-<%= currentUser.userid %>">Change Role:</label> |
102 | | - <select id="role-<%= currentUser.userid %>" class="role-select" data-user-id="<%= currentUser.userid %>"> |
103 | | - <option value="admin" <%= currentUser.role === 'admin' ? 'selected' : '' %>>Admin</option> |
104 | | - <option value="contributor" <%= currentUser.role === 'contributor' ? 'selected' : '' %>>Contributor</option> |
105 | | - <option value="viewer" <%= currentUser.role === 'viewer' ? 'selected' : '' %>>Viewer</option> |
106 | | - </select> |
107 | | - <button class="button primary small update-role-btn" data-user-id="<%= currentUser.userid %>"> |
108 | | - Update |
109 | | - </button> |
| 102 | + <% if (currentUser.isProtected) { %> |
| 103 | + <select id="role-<%= currentUser.userid %>" class="role-select disabled" data-user-id="<%= currentUser.userid %>" disabled title="Protected system account - role cannot be changed"> |
| 104 | + <option value="<%= currentUser.role %>" selected><%= currentUser.role.charAt(0).toUpperCase() + currentUser.role.slice(1) %></option> |
| 105 | + </select> |
| 106 | + <button class="button primary small update-role-btn disabled" data-user-id="<%= currentUser.userid %>" disabled title="Protected system account - role cannot be changed"> |
| 107 | + Update |
| 108 | + </button> |
| 109 | + <% } else { %> |
| 110 | + <select id="role-<%= currentUser.userid %>" class="role-select" data-user-id="<%= currentUser.userid %>"> |
| 111 | + <option value="admin" <%= currentUser.role === 'admin' ? 'selected' : '' %>>Admin</option> |
| 112 | + <option value="contributor" <%= currentUser.role === 'contributor' ? 'selected' : '' %>>Contributor</option> |
| 113 | + <option value="viewer" <%= currentUser.role === 'viewer' ? 'selected' : '' %>>Viewer</option> |
| 114 | + </select> |
| 115 | + <button class="button primary small update-role-btn" data-user-id="<%= currentUser.userid %>"> |
| 116 | + Update |
| 117 | + </button> |
| 118 | + <% } %> |
110 | 119 | </div> |
111 | 120 |
|
112 | 121 | <div class="action-buttons"> |
|
240 | 249 | async function updateUserRole(event) { |
241 | 250 | const userId = event.target.dataset.userId; |
242 | 251 | const roleSelect = document.getElementById(`role-${userId}`); |
| 252 | +
|
| 253 | + // Check if the role select is disabled (protected user) |
| 254 | + if (roleSelect.disabled) { |
| 255 | + alert('Cannot modify protected system account'); |
| 256 | + return; |
| 257 | + } |
| 258 | +
|
243 | 259 | const newRole = roleSelect.value; |
244 | 260 |
|
245 | 261 | try { |
|
0 commit comments