forked from verdnatura/salix-front
allow only the user to modify itself
This commit is contained in:
parent
b155547702
commit
72d8cb7c04
|
@ -1,8 +1,9 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, computed, ref } from 'vue';
|
import { onMounted, computed, ref, onUpdated } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
|
import { useState } from 'src/composables/useState';
|
||||||
import { useSession } from 'src/composables/useSession';
|
import { useSession } from 'src/composables/useSession';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
|
@ -15,11 +16,13 @@ const $props = defineProps({
|
||||||
});
|
});
|
||||||
|
|
||||||
onMounted(async () => await fetch());
|
onMounted(async () => await fetch());
|
||||||
|
onUpdated(async () => await fetch());
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { getToken } = useSession();
|
const { getToken } = useSession();
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
|
const state = useState();
|
||||||
|
|
||||||
const entityId = computed(() => {
|
const entityId = computed(() => {
|
||||||
return $props.id || route.params.id;
|
return $props.id || route.params.id;
|
||||||
|
@ -52,10 +55,6 @@ const notificationAcls = ref([]);
|
||||||
const allowedEditing = ref(false);
|
const allowedEditing = ref(false);
|
||||||
|
|
||||||
async function fetch() {
|
async function fetch() {
|
||||||
const token = await getToken();
|
|
||||||
|
|
||||||
const tokenUser = await axios.get(`AccessTokens/${token}/user`);
|
|
||||||
|
|
||||||
const { data } = await axios.get(`Workers/${entityId.value}`, {
|
const { data } = await axios.get(`Workers/${entityId.value}`, {
|
||||||
params: {
|
params: {
|
||||||
filter: JSON.stringify(workerFilter),
|
filter: JSON.stringify(workerFilter),
|
||||||
|
@ -171,7 +170,7 @@ async function fetch() {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tokenUser.data.id == data.user.id) {
|
if (state.getUser().value.id == data.user.id) {
|
||||||
allowedEditing.value = true;
|
allowedEditing.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue