[chore] fix permissions

This commit is contained in:
Tim Gröger 2021-11-16 11:45:22 +01:00
parent 9be678b74f
commit c5bdebb94f
3 changed files with 15 additions and 6 deletions

View File

@ -11,7 +11,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, ref } from 'vue'; import { defineComponent, ref, onMounted } from 'vue';
import MainUserSettings from './settings/MainUserSettings.vue'; import MainUserSettings from './settings/MainUserSettings.vue';
import UserSelector from './UserSelector.vue'; import UserSelector from './UserSelector.vue';
import { useMainStore, useUserStore } from '@flaschengeist/api'; import { useMainStore, useUserStore } from '@flaschengeist/api';
@ -24,6 +24,10 @@ export default defineComponent({
const userStore = useUserStore(); const userStore = useUserStore();
const user = ref(mainStore.currentUser); const user = ref(mainStore.currentUser);
onMounted(() => {
void userStore.getUsers(true)
})
async function updateUser(value: FG.User) { async function updateUser(value: FG.User) {
await userStore.updateUser(value); await userStore.updateUser(value);
user.value = value; user.value = value;

View File

@ -61,14 +61,19 @@ export default defineComponent({
interface Tab { interface Tab {
name: string; name: string;
label: string; label: string;
permissions: Array<string>;
} }
const tabs: Tab[] = [ const tabs: Tab[] = [
{ name: 'user', label: 'Mitglieder' }, { name: 'user', label: 'Mitglieder', permissions: [PERMISSIONS.EDIT_OTHER, PERMISSIONS.SET_ROLES] },
{ name: 'newUser', label: 'Neues Mitglied' }, { name: 'newUser', label: 'Neues Mitglied', permissions: [PERMISSIONS.SET_ROLES] },
{ name: 'roles', label: 'Rollen' }, { name: 'roles', label: 'Rollen', permissions: [PERMISSIONS.ROLES_EDIT] },
]; ];
const _tabs = computed(() => tabs.filter(tab => {
return tab.permissions.every(permission => hasPermission(permission))
}))
const drawer = ref<boolean>(false); const drawer = ref<boolean>(false);
const showDrawer = computed({ const showDrawer = computed({
@ -86,7 +91,7 @@ export default defineComponent({
canEditRoles, canEditRoles,
showDrawer, showDrawer,
tab, tab,
tabs, tabs: _tabs,
}; };
}, },
}); });

View File

@ -25,7 +25,7 @@ import { defineComponent, onBeforeMount, ref } from 'vue';
import Session from '../components/settings/Session.vue'; import Session from '../components/settings/Session.vue';
export default defineComponent({ export default defineComponent({
// name: 'PageName' name: 'UserSettings',
components: { Session, MainUserSettings }, components: { Session, MainUserSettings },
setup() { setup() {
const mainStore = useMainStore(); const mainStore = useMainStore();