mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-19 01:54:04 +00:00
fix resource permission schema (#2116)
* fix: resource permission schema * fix: ResorceType
This commit is contained in:
4
packages/global/support/permission/type.d.ts
vendored
4
packages/global/support/permission/type.d.ts
vendored
@@ -1,11 +1,13 @@
|
|||||||
import { TeamMemberWithUserSchema } from '../user/team/type';
|
import { TeamMemberWithUserSchema } from '../user/team/type';
|
||||||
import { AuthUserTypeEnum, PermissionKeyEnum } from './constant';
|
import { AuthUserTypeEnum, PermissionKeyEnum, PerResourceTypeEnum } from './constant';
|
||||||
|
|
||||||
// PermissionValueType, the type of permission's value is a number, which is a bit field actually.
|
// PermissionValueType, the type of permission's value is a number, which is a bit field actually.
|
||||||
// It is spired by the permission system in Linux.
|
// It is spired by the permission system in Linux.
|
||||||
// The lowest 3 bits present the permission of reading, writing and managing.
|
// The lowest 3 bits present the permission of reading, writing and managing.
|
||||||
// The higher bits are advanced permissions or extended permissions, which could be customized.
|
// The higher bits are advanced permissions or extended permissions, which could be customized.
|
||||||
export type PermissionValueType = number;
|
export type PermissionValueType = number;
|
||||||
|
export type ResourceType = `${PerResourceTypeEnum}`;
|
||||||
|
|
||||||
export type PermissionListType<T = {}> = Record<
|
export type PermissionListType<T = {}> = Record<
|
||||||
T | PermissionKeyEnum,
|
T | PermissionKeyEnum,
|
||||||
{
|
{
|
||||||
|
@@ -2,10 +2,10 @@ import {
|
|||||||
TeamCollectionName,
|
TeamCollectionName,
|
||||||
TeamMemberCollectionName
|
TeamMemberCollectionName
|
||||||
} from '@fastgpt/global/support/user/team/constant';
|
} from '@fastgpt/global/support/user/team/constant';
|
||||||
import { Model, connectionMongo, getMongoModel } from '../../common/mongo';
|
import { connectionMongo, getMongoModel } from '../../common/mongo';
|
||||||
import type { ResourcePermissionType } from '@fastgpt/global/support/permission/type';
|
import type { ResourcePermissionType } from '@fastgpt/global/support/permission/type';
|
||||||
import { PerResourceTypeEnum } from '@fastgpt/global/support/permission/constant';
|
import { PerResourceTypeEnum } from '@fastgpt/global/support/permission/constant';
|
||||||
const { Schema, model, models } = connectionMongo;
|
const { Schema } = connectionMongo;
|
||||||
|
|
||||||
export const ResourcePermissionCollectionName = 'resource_permission';
|
export const ResourcePermissionCollectionName = 'resource_permission';
|
||||||
|
|
||||||
@@ -19,7 +19,8 @@ export const ResourcePermissionSchema = new Schema({
|
|||||||
ref: TeamMemberCollectionName
|
ref: TeamMemberCollectionName
|
||||||
},
|
},
|
||||||
resourceType: {
|
resourceType: {
|
||||||
type: Object.values(PerResourceTypeEnum),
|
type: String,
|
||||||
|
enum: Object.values(PerResourceTypeEnum),
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
permission: {
|
permission: {
|
||||||
|
Reference in New Issue
Block a user