Remove role label array from frontend

- made centralized role array uncentralized again
This commit is contained in:
Christoph Kluge 2023-02-01 14:49:10 +01:00
parent 7fb94c33cf
commit a2ebebd7f6
3 changed files with 4 additions and 18 deletions

View File

@ -143,7 +143,7 @@ func IsValidRole(role string) bool {
func GetValidRoles(user *User) ([5]string, error) {
var vals [5]string
if (!user.HasRole(RoleAdmin)) {
return vals, fmt.Errorf("%#v: only admins are allowed to fetch a list of roles", user.Username)
return vals, fmt.Errorf("%s: only admins are allowed to fetch a list of roles", user.Username)
} else {
return validRoles, nil
}

View File

@ -7,13 +7,6 @@
let message = {msg: '', color: '#d63384'}
let displayMessage = false
let roleLabel = {
api: 'API',
user: 'User (regular user, same as if created via LDAP sync.)',
manager: 'Manager',
support: 'Support',
admin: 'Admin'
}
export let roles = []
@ -86,12 +79,12 @@
{#if i == 0}
<div>
<input type="radio" id={role} name="role" value={role} checked/>
<label for={role}>{roleLabel[role]}</label>
<label for={role}>{role.charAt(0).toUpperCase() + role.slice(1)} (regular user, same as if created via LDAP sync.)</label>
</div>
{:else}
<div>
<input type="radio" id={role} name="role" value={role}/>
<label for={role}>{roleLabel[role]}</label>
<label for={role}>{role.charAt(0).toUpperCase() + role.slice(1)}</label>
</div>
{/if}
{/each}

View File

@ -9,13 +9,6 @@
let displayMessage = false
export let roles = []
let roleLabel = {
api: 'API',
user: 'User',
manager: 'Manager',
support: 'Support',
admin: 'Admin'
}
async function handleAddRole() {
const username = document.querySelector('#role-username').value
@ -96,7 +89,7 @@
<select class="form-select" id="role-select">
<option selected value="">Role...</option>
{#each roles as role}
<option value={role}>{roleLabel[role]}</option>
<option value={role}>{role.charAt(0).toUpperCase() + role.slice(1)}</option>
{/each}
</select>
<!-- PreventDefault on Sveltestrap-Button more complex to achieve than just use good ol' html button -->