Skip to content

Commit f5465de

Browse files
committed
fix: user scope assertion
1 parent 84a2dcc commit f5465de

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@inspatial/cloud",
3-
"version": "0.7.0",
3+
"version": "0.7.1",
44
"license": "Apache-2.0",
55
"exports": {
66
".": "./mod.ts",

src/extension/core-extension.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ export const coreExtension = new CloudExtension("core", {
191191
create: false,
192192
delete: false,
193193
},
194+
194195
user: {
195196
view: true,
196197
modify: false,

src/orm/entry/entry.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ export class Entry<
111111
}
112112

113113
async load(id: IDValue): Promise<void> {
114+
const role = this._inCloud.roles.getRole(this._user?.role as string);
115+
const userScopeField = role.entryPermissions.get(this._name)?.userScope;
114116
this.assertViewPermission();
115117
this._data.clear();
116118
this._modifiedValues.clear();
@@ -127,6 +129,13 @@ export class Entry<
127129
if (!this._fields.has(key)) {
128130
continue;
129131
}
132+
if (key === userScopeField && value !== this._user?.userId) {
133+
raiseORMException(
134+
`You do not have permission to view this ${this._entryType.config.label}`,
135+
"PermissionDenied",
136+
403,
137+
);
138+
}
130139
const fieldDef = this._getFieldDef(key);
131140
const fieldType = this._getFieldType(fieldDef.type);
132141
this._data.set(key, fieldType.parseDbValue(value, fieldDef));

src/orm/migrate/cloud-migrator.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,6 @@ export class InCloudMigrator extends InCloud {
144144
async #syncFieldMeta(orm: InSpatialORM) {
145145
const adminRole = orm.roles.getRole("systemAdmin");
146146
const skipFields = new Set<string>([
147-
"id",
148-
"createdAt",
149-
"updatedAt",
150147
"in__tags",
151148
]);
152149
const syncFields = async (

0 commit comments

Comments
 (0)