95 lines
2.8 KiB
Plaintext
95 lines
2.8 KiB
Plaintext
rules_version = '2';
|
|
|
|
service cloud.firestore {
|
|
match /databases/{database}/documents {
|
|
|
|
// Helper functions
|
|
function isAuthenticated() {
|
|
return request.auth != null;
|
|
}
|
|
|
|
function isOwner(userId) {
|
|
return request.auth.uid == userId;
|
|
}
|
|
|
|
function isTeamMember(teamId) {
|
|
let team = get(/databases/$(database)/documents/teams/$(teamId)).data;
|
|
return team.memberIds.hasAny([request.auth.uid]);
|
|
}
|
|
|
|
// Users - пользователи могут читать и обновлять свой профиль
|
|
match /users/{userId} {
|
|
allow read: if isAuthenticated();
|
|
allow create: if isOwner(userId);
|
|
allow update, delete: if isOwner(userId);
|
|
}
|
|
|
|
// Teams - команды
|
|
match /teams/{teamId} {
|
|
allow read: if isAuthenticated();
|
|
allow create: if isAuthenticated();
|
|
allow update: if isAuthenticated() && isTeamMember(teamId);
|
|
allow delete: if isAuthenticated() && isTeamMember(teamId);
|
|
|
|
// Подколлекции команд
|
|
match /projects/{projectId} {
|
|
allow read: if isAuthenticated();
|
|
allow create: if isAuthenticated();
|
|
allow update, delete: if isAuthenticated();
|
|
}
|
|
}
|
|
|
|
// Projects - проекты
|
|
match /projects/{projectId} {
|
|
allow read: if isAuthenticated();
|
|
allow create: if isAuthenticated();
|
|
allow update, delete: if isAuthenticated();
|
|
}
|
|
|
|
// Tasks - задачи
|
|
match /tasks/{taskId} {
|
|
allow read: if isAuthenticated();
|
|
allow create: if isAuthenticated();
|
|
allow update: if isAuthenticated();
|
|
allow delete: if isAuthenticated();
|
|
}
|
|
|
|
// Mind Maps - карты проектов
|
|
match /mindmaps/{projectId} {
|
|
allow read: if isAuthenticated();
|
|
allow create: if isAuthenticated();
|
|
allow update: if isAuthenticated();
|
|
allow delete: if isAuthenticated();
|
|
|
|
match /nodes/{nodeId} {
|
|
allow read: if isAuthenticated();
|
|
allow create: if isAuthenticated();
|
|
allow update: if isAuthenticated();
|
|
allow delete: if isAuthenticated();
|
|
}
|
|
}
|
|
|
|
// Events - события календаря
|
|
match /events/{eventId} {
|
|
allow read: if isAuthenticated();
|
|
allow create: if isAuthenticated();
|
|
allow update: if isAuthenticated();
|
|
allow delete: if isAuthenticated();
|
|
}
|
|
|
|
// Alarms - будильники
|
|
match /alarms/{alarmId} {
|
|
allow read: if isAuthenticated();
|
|
allow create: if isAuthenticated();
|
|
allow update: if isAuthenticated();
|
|
allow delete: if isAuthenticated();
|
|
}
|
|
|
|
// Settings - настройки
|
|
match /settings/{settingId} {
|
|
allow read: if isAuthenticated();
|
|
allow write: if isAuthenticated();
|
|
}
|
|
}
|
|
}
|