0
0
Fork 0

allow only the user to modify itself

This commit is contained in:
Pau 2022-11-25 11:41:24 +01:00
parent b155547702
commit 72d8cb7c04
1 changed files with 5 additions and 6 deletions

View File

@ -1,8 +1,9 @@
<script setup>
import { onMounted, computed, ref } from 'vue';
import { onMounted, computed, ref, onUpdated } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { useQuasar } from 'quasar';
import { useState } from 'src/composables/useState';
import { useSession } from 'src/composables/useSession';
import axios from 'axios';
@ -15,11 +16,13 @@ const $props = defineProps({
});
onMounted(async () => await fetch());
onUpdated(async () => await fetch());
const route = useRoute();
const { t } = useI18n();
const { getToken } = useSession();
const quasar = useQuasar();
const state = useState();
const entityId = computed(() => {
return $props.id || route.params.id;
@ -52,10 +55,6 @@ const notificationAcls = ref([]);
const allowedEditing = ref(false);
async function fetch() {
const token = await getToken();
const tokenUser = await axios.get(`AccessTokens/${token}/user`);
const { data } = await axios.get(`Workers/${entityId.value}`, {
params: {
filter: JSON.stringify(workerFilter),
@ -171,7 +170,7 @@ async function fetch() {
console.log(e);
}
if (tokenUser.data.id == data.user.id) {
if (state.getUser().value.id == data.user.id) {
allowedEditing.value = true;
}