适配OakUserUnpermittedException的改动
This commit is contained in:
parent
99ec42c975
commit
6105f03d3a
|
|
@ -1678,7 +1678,7 @@ export async function switchTo<
|
||||||
>({ userId }: { userId: string }, context: Cxt) {
|
>({ userId }: { userId: string }, context: Cxt) {
|
||||||
const reallyRoot = context.isReallyRoot();
|
const reallyRoot = context.isReallyRoot();
|
||||||
if (!reallyRoot) {
|
if (!reallyRoot) {
|
||||||
throw new OakUserUnpermittedException();
|
throw new OakUserUnpermittedException('user', { id: 'switchTo', action: 'switch', data: { }, filter: { id: userId }});
|
||||||
}
|
}
|
||||||
const currentUserId = context.getCurrentUserId();
|
const currentUserId = context.getCurrentUserId();
|
||||||
if (currentUserId === userId) {
|
if (currentUserId === userId) {
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,10 @@ export async function mergeUser<ED extends EntityDict & BaseEntityDict, Cxt exte
|
||||||
mergeWechatUser?: true,
|
mergeWechatUser?: true,
|
||||||
}, context: Cxt, innerLogic?: boolean
|
}, context: Cxt, innerLogic?: boolean
|
||||||
) {
|
) {
|
||||||
if (!innerLogic && !context.isRoot()) {
|
|
||||||
throw new OakUserUnpermittedException('不允许执行mergeUser操作');
|
|
||||||
}
|
|
||||||
const { from, to, mergeMobile, mergeEmail, mergeWechatUser } = params;
|
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(from);
|
||||||
assert(to);
|
assert(to);
|
||||||
assert(from !== to, '不能merge到相同user');
|
assert(from !== to, '不能merge到相同user');
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ const checkers: Checker<EntityDict, 'user', RuntimeCxt> [] = [
|
||||||
entity: 'user',
|
entity: 'user',
|
||||||
relationFilter: () => {
|
relationFilter: () => {
|
||||||
// 只有root才能进行操作
|
// 只有root才能进行操作
|
||||||
throw new OakUserUnpermittedException();
|
throw new OakUserUnpermittedException('user', { id: 'disable', action: 'disable', data: {} });
|
||||||
},
|
},
|
||||||
errMsg: '越权操作',
|
errMsg: '越权操作',
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -230,9 +230,6 @@ export class Token<
|
||||||
}
|
}
|
||||||
|
|
||||||
async switchTo(userId: string) {
|
async switchTo(userId: string) {
|
||||||
if (!this.isReallyRoot()) {
|
|
||||||
throw new OakUserUnpermittedException();
|
|
||||||
}
|
|
||||||
const currentUserId = this.getUserId();
|
const currentUserId = this.getUserId();
|
||||||
if (currentUserId === userId) {
|
if (currentUserId === userId) {
|
||||||
throw new OakRowInconsistencyException(
|
throw new OakRowInconsistencyException(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue