-
Notifications
You must be signed in to change notification settings - Fork 1
/
firestore.rules
24 lines (24 loc) · 1.15 KB
/
firestore.rules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow read: if(request.auth.uid == userId);
allow write: if(request.auth.uid == userId) &&
request.resource.data.keys().hasOnly(['email', 'experiments', 'osfToken', 'osfTokenValid', 'uid']) &&
(request.resource.data.uid == userId);
}
match /experiments/{experimentId} {
function verifyFields(){
return request.resource.data.keys().hasOnly(['active', 'activeBase64', 'activeConditionAssignment', 'id', 'osfRepo', 'osfComponent', 'osfFilesLink', 'owner', 'title', 'sessions', 'nConditions', 'currentCondition', 'useValidation', 'allowJSON', 'allowCSV', 'requiredFields', 'maxSessions', 'limitSessions'])
}
allow read: if(request.auth.uid != null) &&
resource.data.owner == request.auth.uid;
allow create: if(request.auth.uid != null) &&
verifyFields() &&
request.resource.data.owner == request.auth.uid;
allow update: if(request.auth.uid == resource.data.owner) &&
verifyFields();
allow delete: if(request.auth.uid == resource.data.owner);
}
}
}