@galadrim/galadmin 0.1.145 → 0.1.146
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.js +8 -0
- package/dist/api.js.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +1 -0
- package/package.json +1 -1
- package/src/api.ts +0 -2
- package/src/index.ts +8 -1
- package/src/types/config.ts +1 -0
package/dist/types/config.d.ts
CHANGED
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -90,7 +90,6 @@ export default (db, config, user) => {
|
|
|
90
90
|
|
|
91
91
|
app.get('/config', async (req, res) => {
|
|
92
92
|
try {
|
|
93
|
-
/*
|
|
94
93
|
config = {
|
|
95
94
|
...config,
|
|
96
95
|
...{
|
|
@@ -102,7 +101,6 @@ export default (db, config, user) => {
|
|
|
102
101
|
view.columns = view.columns.filter(column => !column.roles || column.roles.includes(user.role))
|
|
103
102
|
}
|
|
104
103
|
}
|
|
105
|
-
*/
|
|
106
104
|
const { mysql, auth, sessionSecret, ...safeConfig } = config;
|
|
107
105
|
res.send({
|
|
108
106
|
config: serializeJs(safeConfig)
|
package/src/index.ts
CHANGED
|
@@ -151,7 +151,14 @@ export default (config: Config): any => {
|
|
|
151
151
|
app.use("/api", (req, res, next) => {
|
|
152
152
|
return api(db, {
|
|
153
153
|
...config,
|
|
154
|
-
views: config.views
|
|
154
|
+
views: config.views
|
|
155
|
+
.filter(x => !x.roles
|
|
156
|
+
|| (req.session.user && ([...(x.roles || []), ...(x.readRoles || [])].includes(req.session.user.role)))
|
|
157
|
+
)
|
|
158
|
+
.map(view => ({
|
|
159
|
+
...view,
|
|
160
|
+
...(view.type === "table" && view.canEdit !== false ? { canEdit: (req.session.user && view.roles.includes(req.session.user.role)) } : {}),
|
|
161
|
+
}))
|
|
155
162
|
}, req.session.user)(req, res, next)
|
|
156
163
|
})
|
|
157
164
|
|