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"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kevisual/code-center-module": "^0.0.9",
|
||||
"@kevisual/code-center-module": "0.0.11-alpha.1",
|
||||
"@kevisual/types": "^0.0.6",
|
||||
"@rollup/plugin-alias": "^5.1.1",
|
||||
"@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
|
||||
devDependencies:
|
||||
'@kevisual/code-center-module':
|
||||
specifier: ^0.0.9
|
||||
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))
|
||||
specifier: 0.0.11-alpha.1
|
||||
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':
|
||||
specifier: ^0.0.6
|
||||
version: 0.0.6
|
||||
@ -351,8 +351,8 @@ packages:
|
||||
'@kevisual/auth@1.0.5':
|
||||
resolution: {integrity: sha512-GwsLj7unKXi7lmMiIIgdig4LwwLiDJnOy15HHZR5gMbyK6s5/uJiMY5RXPB2+onGzTNDqFo/hXjsD2wkerHPVg==}
|
||||
|
||||
'@kevisual/code-center-module@0.0.9':
|
||||
resolution: {integrity: sha512-ErHTYUlJGXmeBV5RJezKbBRmTYVBABV0SVvcMvbWVWPNc13Zo5RvM29vnzY6w3b6/cpnpWBi7Vx8WGFrcsMOkw==}
|
||||
'@kevisual/code-center-module@0.0.11-alpha.1':
|
||||
resolution: {integrity: sha512-0HPSZw4PmhejE7p4cBIe174/h434XE3dgrwHoRZLYZSZyJ/aaBfR+3RybdvDN5dnyusLkPdgRq+Qern53Lqp1A==}
|
||||
peerDependencies:
|
||||
'@kevisual/auth': ^1.0.5
|
||||
'@kevisual/router': ^0.0.7
|
||||
@ -2575,7 +2575,7 @@ snapshots:
|
||||
|
||||
'@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:
|
||||
'@kevisual/auth': 1.0.5
|
||||
'@kevisual/router': 0.0.7
|
||||
|
@ -30,12 +30,17 @@ app
|
||||
const tokenAdmin = ctx.state.tokenAdmin;
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
const data = ctx.query.data;
|
||||
const { orgId, userId, action } = data;
|
||||
const { orgId, userId, username, action, role } = data;
|
||||
const org = await Org.findByPk(orgId);
|
||||
if (!org) {
|
||||
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) {
|
||||
ctx.throw('用户不存在');
|
||||
}
|
||||
@ -44,7 +49,7 @@ app
|
||||
}
|
||||
const operateId = tokenUser.uid || tokenUser.id;
|
||||
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') {
|
||||
await org.removeUser(user, { needPermission: true, operateId, isAdmin: !!tokenAdmin });
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user