-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.rules.bolt
70 lines (57 loc) · 1.35 KB
/
database.rules.bolt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
path /config {
read() { isAuthenticated() }
write() { isBarista() }
}
path /roles {
read() { isBarista() }
write() { isBarista() }
}
// Users
path /users {
read() { isBarista() }
write() { isBarista() }
}
path /users/{uid} {
/profile is Profile;
/roles is UserRoles;
/importedOrders is Orders;
/orders is Orders;
}
// Orders
path /orders {
read() { isBarista() }
write() { isBarista() }
index() { [ "status" ] }
}
path /orders/{orderId} {
write() { isOrderOwner() }
}
type Orders extends Order[] {
read() { isCurrentUser(uid) }
write() { isCurrentUser(uid) }
}
type Order {
// TODO: figure out why $other validate false prevents multipath updates
// drink: String;
// temperature: Temperature;
}
type Profile {
read() { isCurrentUser(uid) }
write() { isCurrentUser(uid) }
}
type UserRoles {
read() { isCurrentUser(uid) }
}
type PhoneNumber extends String {
write() { isCurrentUser(uid) }
}
type UpdateProfile extends Boolean {
write() { isCurrentUser(uid) }
}
type Temperature extends String {
validate() { this == 'Hot' || this == 'Iced' }
}
isAuthenticated() { auth != null }
isCurrentUser(uid) { auth != null && auth.uid == uid }
isOrderOwner() { auth != null && auth.uid == newData.child('uid').val() && root['roles/user/' + auth.uid] != null }
isBarista() { auth != null && root['roles/barista/' + auth.uid] != null }