Page MenuHomeSealhub

themselves.ts
No OneTemporary

themselves.ts

import { Context, Policy, Query } from "../../main";
import { CollectionItem } from "../../chip-types/collection-item";
export default class Themselves extends Policy {
static type_name = "themselves";
isItemSensitive = async () => true;
async _getRestrictingQuery(context: Context) {
return Query.fromSingleMatch({
id: { $eq: context.user_id },
});
}
async checkerFunction(
context: Context,
item_getter: () => Promise<CollectionItem>
) {
const user_id = (await item_getter()).id;
if (context.user_id !== user_id) {
return Policy.deny(`you are not the user of id ${user_id}.`);
}
return Policy.allow("you are the user in question");
}
}

File Metadata

Mime Type
text/x-java
Expires
Sat, Oct 11, 12:03 (10 m, 29 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
984333
Default Alt Text
themselves.ts (668 B)

Event Timeline