core: bug fix

fix #68
fix #70
fix #71
This commit is contained in:
undefined committed 2021-03-29 01:57:13 +08:00
1 parent ee4dc90cf3
commit 1472c1567c
8 files changed
+48 -23

No files matched your search

+8 -1
View File
@@ -21,7 +21,7 @@ const logger = new Logger('upgrade');
type UpgradeScript = () => Promise<boolean | void>;
async function iterateAllDomain(cb: (ddoc: DomainDoc, current?: number, total?: number) => Promise<any>) {
const ddocs = await domain.getMulti().project({ _id: 1 }).toArray();
const ddocs = await domain.getMulti().project({ _id: 1, owner: 1 }).toArray();
for (const i in ddocs) await cb(ddocs[i], +i, ddocs.length);
}
@@ -220,6 +220,13 @@ const scripts: UpgradeScript[] = [
});
return true;
},
// Set domain owner perm
async function _13_14() {
const _FRESH_INSTALL_IGNORE = 1;
await iterateAllDomain((ddoc) => domain.setUserRole(ddoc._id, ddoc.owner, 'root'));
await db.collection('domain.user').updateMany({ role: 'admin' }, { $set: { role: 'root' } });
return true;
},
];
export = scripts;