purge old permission (#2118)
* chore: purge old permission - remove useless role of teamMember - Cleanup auth apis' Props and Return type Definitions * chore: a better way of RequireAtLeastOne Signed-off-by: Finley Ge <m13203533462@163.com> --------- Signed-off-by: Finley Ge <m13203533462@163.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import { jsonRes } from '@fastgpt/service/common/response';
|
||||
import { connectToDatabase } from '@/service/mongo';
|
||||
import { MongoOpenApi } from '@fastgpt/service/support/openapi/schema';
|
||||
import { authOpenApiKeyCrud } from '@fastgpt/service/support/permission/auth/openapi';
|
||||
import { OwnerPermissionVal } from '@fastgpt/global/support/permission/constant';
|
||||
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
try {
|
||||
@@ -13,7 +14,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
throw new Error('缺少参数');
|
||||
}
|
||||
|
||||
await authOpenApiKeyCrud({ req, authToken: true, id, per: 'owner' });
|
||||
await authOpenApiKeyCrud({ req, authToken: true, id, per: OwnerPermissionVal });
|
||||
|
||||
await MongoOpenApi.findOneAndRemove({ _id: id });
|
||||
|
||||
|
||||
@@ -4,13 +4,14 @@ import { connectToDatabase } from '@/service/mongo';
|
||||
import { MongoOpenApi } from '@fastgpt/service/support/openapi/schema';
|
||||
import type { EditApiKeyProps } from '@/global/support/openapi/api.d';
|
||||
import { authOpenApiKeyCrud } from '@fastgpt/service/support/permission/auth/openapi';
|
||||
import { OwnerPermissionVal } from '@fastgpt/global/support/permission/constant';
|
||||
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
try {
|
||||
await connectToDatabase();
|
||||
const { _id, name, limit } = req.body as EditApiKeyProps & { _id: string };
|
||||
|
||||
await authOpenApiKeyCrud({ req, authToken: true, id: _id, per: 'owner' });
|
||||
await authOpenApiKeyCrud({ req, authToken: true, id: _id, per: OwnerPermissionVal });
|
||||
|
||||
await MongoOpenApi.findByIdAndUpdate(_id, {
|
||||
...(name && { name }),
|
||||
|
||||
Reference in New Issue
Block a user