Browse Source

Prevent user from editing their own role

Kristan Kenney 5 years ago
parent
commit
63fa65bf25
1 changed files with 15 additions and 13 deletions
  1. 15 13
      web/templates/admin/edit_user.html

+ 15 - 13
web/templates/admin/edit_user.html

@@ -163,19 +163,21 @@
                             <?php if ($v_username == 'admin') {?>
                                 <!-- Hide option to change 'admin' user's role-->
                             <? } else { ?>
-                            <tr>
-                                <td class="vst-text input-label">
-                                    <?php print _('Role');?>
-                                </td>
-                            </tr>
-                            <tr>
-                                <td>
-                                    <select class="vst-list" name="v_role">
-                                        <option value="user"><?php print _('User');?>
-                                        <option value="admin" <?php if($v_role == "admin" ){ echo "selected"; } ?> ><?php print _('Administrator');?>
-                                    </select>
-                                </td>
-                            </tr>
+                                <? if (($_SESSION['userContext'] === 'admin') && ($_SESSION['user'] != $v_username)) {?>
+                                <tr>
+                                    <td class="vst-text input-label">
+                                        <?php print _('Role');?>
+                                    </td>
+                                </tr>
+                                <tr>
+                                    <td>
+                                        <select class="vst-list" name="v_role">
+                                            <option value="user"><?php print _('User');?>
+                                            <option value="admin" <?php if($v_role == "admin" ){ echo "selected"; } ?> ><?php print _('Administrator');?>
+                                        </select>
+                                    </td>
+                                </tr>
+                                <? } ?>
                             <? } ?>
                             <tr>
                                 <td class="vst-text input-label">