fix: fix no user type for admin user to group
This commit is contained in:
parent
d2280f6b89
commit
c482092961
@ -57,7 +57,7 @@
|
|||||||
"zod": "^3.24.2"
|
"zod": "^3.24.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@kevisual/code-center-module": "^0.0.9",
|
"@kevisual/code-center-module": "0.0.11-alpha.1",
|
||||||
"@kevisual/types": "^0.0.6",
|
"@kevisual/types": "^0.0.6",
|
||||||
"@rollup/plugin-alias": "^5.1.1",
|
"@rollup/plugin-alias": "^5.1.1",
|
||||||
"@rollup/plugin-commonjs": "^28.0.2",
|
"@rollup/plugin-commonjs": "^28.0.2",
|
||||||
|
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
@ -96,8 +96,8 @@ importers:
|
|||||||
version: 3.24.2
|
version: 3.24.2
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@kevisual/code-center-module':
|
'@kevisual/code-center-module':
|
||||||
specifier: ^0.0.9
|
specifier: 0.0.11-alpha.1
|
||||||
version: 0.0.9(@kevisual/auth@1.0.5)(@kevisual/router@0.0.7)(@kevisual/use-config@1.0.8)(ioredis@5.5.0)(pg@8.13.3)(sequelize@6.37.5(pg@8.13.3))
|
version: 0.0.11-alpha.1(@kevisual/auth@1.0.5)(@kevisual/router@0.0.7)(@kevisual/use-config@1.0.8)(ioredis@5.5.0)(pg@8.13.3)(sequelize@6.37.5(pg@8.13.3))
|
||||||
'@kevisual/types':
|
'@kevisual/types':
|
||||||
specifier: ^0.0.6
|
specifier: ^0.0.6
|
||||||
version: 0.0.6
|
version: 0.0.6
|
||||||
@ -351,8 +351,8 @@ packages:
|
|||||||
'@kevisual/auth@1.0.5':
|
'@kevisual/auth@1.0.5':
|
||||||
resolution: {integrity: sha512-GwsLj7unKXi7lmMiIIgdig4LwwLiDJnOy15HHZR5gMbyK6s5/uJiMY5RXPB2+onGzTNDqFo/hXjsD2wkerHPVg==}
|
resolution: {integrity: sha512-GwsLj7unKXi7lmMiIIgdig4LwwLiDJnOy15HHZR5gMbyK6s5/uJiMY5RXPB2+onGzTNDqFo/hXjsD2wkerHPVg==}
|
||||||
|
|
||||||
'@kevisual/code-center-module@0.0.9':
|
'@kevisual/code-center-module@0.0.11-alpha.1':
|
||||||
resolution: {integrity: sha512-ErHTYUlJGXmeBV5RJezKbBRmTYVBABV0SVvcMvbWVWPNc13Zo5RvM29vnzY6w3b6/cpnpWBi7Vx8WGFrcsMOkw==}
|
resolution: {integrity: sha512-0HPSZw4PmhejE7p4cBIe174/h434XE3dgrwHoRZLYZSZyJ/aaBfR+3RybdvDN5dnyusLkPdgRq+Qern53Lqp1A==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
'@kevisual/auth': ^1.0.5
|
'@kevisual/auth': ^1.0.5
|
||||||
'@kevisual/router': ^0.0.7
|
'@kevisual/router': ^0.0.7
|
||||||
@ -2575,7 +2575,7 @@ snapshots:
|
|||||||
|
|
||||||
'@kevisual/auth@1.0.5': {}
|
'@kevisual/auth@1.0.5': {}
|
||||||
|
|
||||||
'@kevisual/code-center-module@0.0.9(@kevisual/auth@1.0.5)(@kevisual/router@0.0.7)(@kevisual/use-config@1.0.8)(ioredis@5.5.0)(pg@8.13.3)(sequelize@6.37.5(pg@8.13.3))':
|
'@kevisual/code-center-module@0.0.11-alpha.1(@kevisual/auth@1.0.5)(@kevisual/router@0.0.7)(@kevisual/use-config@1.0.8)(ioredis@5.5.0)(pg@8.13.3)(sequelize@6.37.5(pg@8.13.3))':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@kevisual/auth': 1.0.5
|
'@kevisual/auth': 1.0.5
|
||||||
'@kevisual/router': 0.0.7
|
'@kevisual/router': 0.0.7
|
||||||
|
@ -30,12 +30,17 @@ app
|
|||||||
const tokenAdmin = ctx.state.tokenAdmin;
|
const tokenAdmin = ctx.state.tokenAdmin;
|
||||||
const tokenUser = ctx.state.tokenUser;
|
const tokenUser = ctx.state.tokenUser;
|
||||||
const data = ctx.query.data;
|
const data = ctx.query.data;
|
||||||
const { orgId, userId, action } = data;
|
const { orgId, userId, username, action, role } = data;
|
||||||
const org = await Org.findByPk(orgId);
|
const org = await Org.findByPk(orgId);
|
||||||
if (!org) {
|
if (!org) {
|
||||||
ctx.throw('组织不存在');
|
ctx.throw('组织不存在');
|
||||||
}
|
}
|
||||||
const user = await User.findByPk(userId);
|
let user: User;
|
||||||
|
if (userId) {
|
||||||
|
user = await User.findByPk(userId);
|
||||||
|
} else if (username) {
|
||||||
|
user = await User.findOne({ where: { username } });
|
||||||
|
}
|
||||||
if (!user) {
|
if (!user) {
|
||||||
ctx.throw('用户不存在');
|
ctx.throw('用户不存在');
|
||||||
}
|
}
|
||||||
@ -44,7 +49,7 @@ app
|
|||||||
}
|
}
|
||||||
const operateId = tokenUser.uid || tokenUser.id;
|
const operateId = tokenUser.uid || tokenUser.id;
|
||||||
if (action === 'add') {
|
if (action === 'add') {
|
||||||
await org.addUser(user, { needPermission: true, role: 'user', operateId, isAdmin: !!tokenAdmin });
|
await org.addUser(user, { needPermission: true, role: role || 'user', operateId, isAdmin: !!tokenAdmin });
|
||||||
} else if (action === 'remove') {
|
} else if (action === 'remove') {
|
||||||
await org.removeUser(user, { needPermission: true, operateId, isAdmin: !!tokenAdmin });
|
await org.removeUser(user, { needPermission: true, operateId, isAdmin: !!tokenAdmin });
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user