diff --git a/public/main.js b/public/main.js index 40f6920..7ff9c87 100644 --- a/public/main.js +++ b/public/main.js @@ -110,7 +110,7 @@ async function createTask(event) { alert('Требуется аутентификация'); return; } - + const title = document.getElementById('title').value; const description = document.getElementById('description').value; const taskType = document.getElementById('task-type').value; @@ -143,6 +143,17 @@ async function createTask(event) { formData.append('files', files[i]); } + // Проверка прав для типа "regular" + const userGroups = currentUser?.groups || []; + const isAdmin = currentUser?.role === 'admin'; + const hasTasksGroup = currentUser?.role === 'tasks'; + const hasSecretaryGroup = currentUser?.role === 'secretary'; + + if (taskType === 'regular' && !(isAdmin || hasTasksGroup || hasSecretaryGroup)) { + alert('У вас нет прав для создания обычных задач. Выберите другой тип задачи.'); + return; + } + try { const response = await fetch('/api/tasks', { method: 'POST',