core: restore PERM_EDIT_PROBLEM_SELF

This commit is contained in:
undefined committed 2021-05-08 22:44:04 +08:00
1 parent 5b0478fb3f
commit 866aa56f78
11 files changed
+25 -21

No files matched your search

-1
View File
@@ -26,7 +26,6 @@ export const PERM = {
// Problem and Record
PERM_CREATE_PROBLEM: 1n << 4n,
PERM_EDIT_PROBLEM: 1n << 5n,
/** @deprecated */
PERM_EDIT_PROBLEM_SELF: 1n << 6n,
PERM_VIEW_PROBLEM: 1n << 7n,
PERM_VIEW_PROBLEM_HIDDEN: 1n << 8n,
+3 -2
View File
@@ -87,8 +87,9 @@ class User implements _User {
return this;
}
own<T extends { owner: number, maintainer?: number[] }>(doc: T, exact = false) {
return exact
own(doc: any, arg1: any = false): boolean {
if (typeof arg1 === 'bigint' && !this.hasPerm(arg1)) return false;
return (typeof arg1 === 'boolean' && arg1)
? doc.owner === this._id
: doc.owner === this._id || (doc.maintainer || []).includes(this._id);
}