适配OakUserUnpermittedException的改动

This commit is contained in:
Xu Chang 2024-01-10 15:30:11 +08:00
parent 99ec42c975
commit 6105f03d3a
4 changed files with 5 additions and 8 deletions

View File

@ -1678,7 +1678,7 @@ export async function switchTo<
>({ userId }: { userId: string }, context: Cxt) {
const reallyRoot = context.isReallyRoot();
if (!reallyRoot) {
throw new OakUserUnpermittedException();
throw new OakUserUnpermittedException('user', { id: 'switchTo', action: 'switch', data: { }, filter: { id: userId }});
}
const currentUserId = context.getCurrentUserId();
if (currentUserId === userId) {

View File

@ -16,10 +16,10 @@ export async function mergeUser<ED extends EntityDict & BaseEntityDict, Cxt exte
mergeWechatUser?: true,
}, context: Cxt, innerLogic?: boolean
) {
if (!innerLogic && !context.isRoot()) {
throw new OakUserUnpermittedException('不允许执行mergeUser操作');
}
const { from, to, mergeMobile, mergeEmail, mergeWechatUser } = params;
if (!innerLogic && !context.isRoot()) {
throw new OakUserUnpermittedException('user', { id: 'merge', action: 'merge', data: { userId: to }}, '不允许执行mergeUser操作');
}
assert(from);
assert(to);
assert(from !== to, '不能merge到相同user');

View File

@ -19,7 +19,7 @@ const checkers: Checker<EntityDict, 'user', RuntimeCxt> [] = [
entity: 'user',
relationFilter: () => {
// 只有root才能进行操作
throw new OakUserUnpermittedException();
throw new OakUserUnpermittedException('user', { id: 'disable', action: 'disable', data: {} });
},
errMsg: '越权操作',
},

View File

@ -230,9 +230,6 @@ export class Token<
}
async switchTo(userId: string) {
if (!this.isReallyRoot()) {
throw new OakUserUnpermittedException();
}
const currentUserId = this.getUserId();
if (currentUserId === userId) {
throw new OakRowInconsistencyException(