Browse Source

Change UX/security for modifying user permissions

master
Jared 1 year ago
parent
commit
495e81d386
1 changed files with 10 additions and 7 deletions
  1. +10
    -7
      src/views/ModifyUserView.vue

+ 10
- 7
src/views/ModifyUserView.vue View File

@@ -2,19 +2,19 @@
<section class="section"> <section class="section">
<table> <table>
<tr> <tr>
<th>
<th class="p-2">
Username Username
</th> </th>
<th>
<th class="p-2">
Password Password
</th> </th>
<th>
<th class="p-2">
Privileges Privileges
</th> </th>
</tr> </tr>
<tr v-for="user in users" :key="user.username"> <tr v-for="user in users" :key="user.username">
<td>{{ user.username }}</td>
<td>
<td class="p-2">{{ user.username }}</td>
<td class="p-2">
<template v-if="userData.username === user.username || userData.privileges < 2"> <template v-if="userData.username === user.username || userData.privileges < 2">
<input type="password" <input type="password"
class="input is-small" :aria-label="`${user.username}'s Password`"> class="input is-small" :aria-label="`${user.username}'s Password`">
@@ -23,7 +23,7 @@
******** ********
</template> </template>
</td> </td>
<td>
<td class="p-2">
<select class="select is-small" name="" id="" aria-label="User Privilege"> <select class="select is-small" name="" id="" aria-label="User Privilege">
<option :value="privilege" <option :value="privilege"
:selected="getPrivilege(user.admin) === privilege" :selected="getPrivilege(user.admin) === privilege"
@@ -63,7 +63,7 @@ const getPrivilege = (privilege: number) => Privileges[privilege];


const getPrivileges = () => Object.fromEntries( const getPrivileges = () => Object.fromEntries(
Object.entries(Privileges) Object.entries(Privileges)
.filter((p) => /^[0-9]+$/.test(p[1].toString()))
.filter((p) => /^[0-9]+$/.test(p[1].toString()) && p[1] >= userData.value.privileges)
.map((p) => p.reverse()), .map((p) => p.reverse()),
); );


@@ -80,4 +80,7 @@ table th


table td table td
font-family monospace font-family monospace

table th, td
border 1px solid #aeaeae
</style> </style>

Loading…
Cancel
Save