права на обычные задачи

This commit is contained in:
2026-02-03 14:16:36 +05:00
parent ce8b45798f
commit 70247bb3d8

View File

@@ -110,7 +110,7 @@ async function createTask(event) {
alert('Требуется аутентификация'); alert('Требуется аутентификация');
return; return;
} }
const title = document.getElementById('title').value; const title = document.getElementById('title').value;
const description = document.getElementById('description').value; const description = document.getElementById('description').value;
const taskType = document.getElementById('task-type').value; const taskType = document.getElementById('task-type').value;
@@ -143,6 +143,17 @@ async function createTask(event) {
formData.append('files', files[i]); 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 { try {
const response = await fetch('/api/tasks', { const response = await fetch('/api/tasks', {
method: 'POST', method: 'POST',