fix
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm">
|
||||
<div v-if="user.id === currentUserId" class="text-xs text-gray-500">{{ t('users.you') }}</div>
|
||||
<div v-if="user.id === userStore.id" class="text-xs text-gray-500">{{ t('users.you') }}</div>
|
||||
<label v-else class="relative inline-flex items-center cursor-pointer">
|
||||
<input
|
||||
type="checkbox"
|
||||
@@ -57,7 +57,7 @@
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
v-if="user.id !== currentUserId"
|
||||
v-if="user.id !== userStore.id"
|
||||
@click="confirmDelete(user.id)"
|
||||
class="text-red-600 hover:text-red-800 transition-colors"
|
||||
>
|
||||
@@ -164,7 +164,6 @@ const { t } = useI18n();
|
||||
const { showNotification } = useNotification();
|
||||
const userStore = useUserStore();
|
||||
|
||||
const currentUserId = ref<number | null>(null);
|
||||
const users = ref<any[]>([]);
|
||||
const modalOpen = ref(false);
|
||||
const modalMode = ref<'create' | 'edit'>('create');
|
||||
@@ -173,23 +172,9 @@ const modalTitle = ref('');
|
||||
const deleteConfirm = ref({ show: false, id: null });
|
||||
|
||||
const isEditingSelf = computed(() => {
|
||||
return modalMode.value === 'edit' && form.value.id === currentUserId.value;
|
||||
return modalMode.value === 'edit' && form.value.id === userStore.id;
|
||||
});
|
||||
|
||||
async function loadCurrentUser() {
|
||||
try {
|
||||
const res = await fetch('/api/admin/me');
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
currentUserId.value = data.id;
|
||||
} else {
|
||||
showNotification('users.loadCurrentError', 'error');
|
||||
}
|
||||
} catch (e) {
|
||||
showNotification('common.networkError', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async function loadUsers() {
|
||||
try {
|
||||
const res = await fetch('/api/admin/users');
|
||||
@@ -297,7 +282,6 @@ async function deleteUser(id: number) {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await loadCurrentUser();
|
||||
await loadUsers();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -316,21 +316,6 @@ public class MainVerticle extends AbstractVerticle {
|
||||
.onFailure(err -> rc.response().setStatusCode(500).end(err.getMessage()));
|
||||
});
|
||||
|
||||
// Получение текущего пользователя
|
||||
router.get("/api/admin/me").handler(rc -> {
|
||||
Integer userId = rc.session().get("userId");
|
||||
if (userId != null) {
|
||||
rc.response()
|
||||
.putHeader("Content-Type", "application/json")
|
||||
.end(new JsonObject()
|
||||
.put("id", userId)
|
||||
.put("login", rc.session().get("login"))
|
||||
.encode());
|
||||
} else {
|
||||
rc.response().setStatusCode(401).end();
|
||||
}
|
||||
});
|
||||
|
||||
router.get("/api/admin/restaurants").handler(rc -> restaurantService.getAllRestaurants().onComplete(ar -> {
|
||||
if (ar.succeeded()) {
|
||||
rc.response()
|
||||
|
||||
Reference in New Issue
Block a user