Skip to content

Commit 58cf5c9

Browse files
authored
Merge pull request #116 from icefoganalytics/issue-106/lock-down-user-group-info
Locking down user group info
2 parents c248d44 + d7007e0 commit 58cf5c9

File tree

9 files changed

+368
-34
lines changed

9 files changed

+368
-34
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ typings/
7070

7171
# dotenv environment variables file
7272
.env
73+
.envrc
7374
.env.test
7475
.env.production
7576

@@ -109,3 +110,8 @@ db/sapassword.env
109110

110111
# DB Data
111112
db/data
113+
114+
# Other
115+
note.md
116+
notes.md
117+
now.sql

api/src/policies/users-policy.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Path } from "@/utils/deep-pick"
22
import { User } from "@/models"
3-
import { RoleTypes } from "@/models/role"
43

54
import BasePolicy from "@/policies/base-policy"
65

@@ -13,34 +12,34 @@ export class UsersPolicy extends BasePolicy<User> {
1312
}
1413

1514
create(): boolean {
16-
if (this.user.roleTypes.includes(RoleTypes.SYSTEM_ADMIN)) return true
15+
if (this.user.isSystemAdmin) return true
1716

1817
return false
1918
}
2019

2120
update(): boolean {
22-
if (this.user.roleTypes.includes(RoleTypes.SYSTEM_ADMIN)) return true
21+
if (this.user.isSystemAdmin) return true
2322
if (this.user.id === this.record.id) return true
2423

2524
return false
2625
}
2726

2827
destroy(): boolean {
29-
if (this.user.roleTypes.includes(RoleTypes.SYSTEM_ADMIN)) return true
28+
if (this.user.isSystemAdmin) return true
3029

3130
return false
3231
}
3332

3433
permittedAttributes(): Path[] {
35-
return [
36-
"email",
37-
"firstName",
38-
"lastName",
39-
"position",
40-
{
34+
const attributes: Path[] = ["email", "firstName", "lastName", "position"]
35+
36+
if (this.user.isSystemAdmin) {
37+
attributes.push({
4138
groupMembershipAttributes: ["departmentId", "divisionId", "branchId", "unitId"],
42-
},
43-
]
39+
})
40+
}
41+
42+
return attributes
4443
}
4544

4645
permittedAttributesForCreate(): Path[] {

docker-compose.development.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,20 @@ services:
115115

116116
mail:
117117
image: maildev/maildev
118+
user: root
118119
ports:
119120
- "1080:1080" # Web UI
120121
- "1025:1025" # SMTP
121122

122123
# For easily generating large PlantUML diagrams
123124
# Not relevant to production environment.
124125
# Accessible at http://localhost:9999
125-
plantuml:
126-
image: plantuml/plantuml-server:jetty
127-
ports:
128-
- 9999:8080
129-
environment:
130-
PLANTUML_LIMIT_SIZE: 8192
126+
# plantuml:
127+
# image: plantuml/plantuml-server:jetty
128+
# ports:
129+
# - 9999:8080
130+
# environment:
131+
# PLANTUML_LIMIT_SIZE: 8192
131132

132133
volumes:
133134
db_data:

0 commit comments

Comments
 (0)