Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission #1442

Merged
merged 20 commits into from May 17, 2024
Merged

Permission #1442

merged 20 commits into from May 17, 2024

Conversation

FinleyGe
Copy link
Contributor

No description provided.

Copy link

cla-assistant bot commented May 10, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ c121914yu
❌ FinleyGe
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
Copy link

cla-assistant bot commented May 10, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ c121914yu
❌ FinleyGe
You have signed the CLA already but the status is still pending? Let us recheck it.

@@ -9,3 +9,17 @@ export type AuthResponseType = {
appId?: string;
apikey?: string;
};

export type MetaDataType = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

稍微完善下主语


export type ResourcePermissionType = {
metaData: MetaDataType;
userPermissionTable: Array<{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

统一用[]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment the defaultPermission

});

export const MongoUserPermission: Model<SchemaType> =
models['user_permission'] || model('user_permission', UserPermissionSchema);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复用下面名。
这里是用户的还是团队的?
用 user.xxx 这类命名吧,和其他集合一样。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不用 schema

},
{
label: '权限',
value: 'permission'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

创个枚举

@@ -128,7 +123,23 @@ const TeamManageModal = ({ onClose }: { onClose: () => void }) => {
});

return !!userInfo?.team ? (
<>
<TeamContext.Provider
value={{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有些方法,只有一个地方用到,不需要都塞 context


export type ResourcePermissionType = {
metaData: MetaDataType;
userPermissionTable: Array<{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment the defaultPermission

export type ResourcePermissionType = {
metaData: MetaDataType;
userPermissionTable: Array<{
user: UserModelSchema;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user should be string.
user -> memberId.

role: `${TeamMemberRoleEnum}`;
status: `${TeamMemberStatusEnum}`;
permission: number;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type should be PermissionValueType

}

// check the permission
export function checkPermission(val: PermissionValueType, perm: PermissionType): boolean {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perm: PermissionValueType

export type PermissionValueType = number;
export type PermissionType = [string, PermissionValueType];

export const ReadPerm: PermissionType = ['Read', 0b100];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

turn the 3 permissions list into a object, which is able to be extended.


export type UpdateTeamMemberPermissionProps = {
teamId: string;
memberId: string[];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memberIdList

});

export const MongoUserPermission: Model<SchemaType> =
models['user_permission'] || model('user_permission', UserPermissionSchema);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不用 schema

@@ -46,6 +47,9 @@ const TeamSchema = new Schema({
pat: {
type: String
}
},
resourcePermission: {
type: ResourcePermissonSchema
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

写成对象

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete this file

@FinleyGe FinleyGe force-pushed the permission branch 3 times, most recently from 29183bb to 050b981 Compare May 16, 2024 07:42
return (await MongoResourcePermission.findOne({
tmbId,
resourceType
}).exec()) as ResourcePermissionType;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exec?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

之前这个查询一直有问题,各种尝试的过程中加上去的 exec 。。功能上没有什么区别,可以删掉,参考:
https://stackoverflow.com/a/68469848/10794921

@@ -0,0 +1 @@
export const ResourcePermissionCollectionName = 'resource_permission';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个直接放到schema文件里export就ok了

}

export function constructPermission(permList: PermissionValueType[]) {
return new Permission(0).add(...permList);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0是什么

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那就写一个新的 NullPermission = 0 语义化以下

@@ -13,6 +13,10 @@ const TeamSchema = new Schema({
type: Schema.Types.ObjectId,
ref: userCollectionName
},
defaultPermission: {
type: Number,
default: 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0能不能找个变量替换,不好理解

@c121914yu c121914yu merged commit e59696f into labring:permission May 17, 2024
1 check was pending
c121914yu added a commit to c121914yu/FastGPT that referenced this pull request May 17, 2024
* Revert "lafAccount add pat & re request when token invalid (#76)" (#77)

This reverts commit 83d85df.

* feat: add permission display in the team manager modal

* feat: add permission i18n

* feat: let team module acquire permission ablity

* feat: add ownerPermission property into metaData

* feat: team premission system

* feat: extract the resourcePermission from resource schemas

* fix: move enum definition to constant

* feat: auth member permission handler, invite user

* feat: permission manage

* feat: adjust the style

* feat: team card style
- add a new icon

* feat: team permission in guest mode

* chore: change the type

* chore: delete useless file

* chore: delete useless code

* feat: do not show owner in PermissionManage view

* chore: fix style

* fix: icon remove fill

* feat: adjust the codes

---------

Co-authored-by: Archer <545436317@qq.com>
c121914yu added a commit that referenced this pull request May 17, 2024
* Permission (#1442)

* Revert "lafAccount add pat & re request when token invalid (#76)" (#77)

This reverts commit 83d85df.

* feat: add permission display in the team manager modal

* feat: add permission i18n

* feat: let team module acquire permission ablity

* feat: add ownerPermission property into metaData

* feat: team premission system

* feat: extract the resourcePermission from resource schemas

* fix: move enum definition to constant

* feat: auth member permission handler, invite user

* feat: permission manage

* feat: adjust the style

* feat: team card style
- add a new icon

* feat: team permission in guest mode

* chore: change the type

* chore: delete useless file

* chore: delete useless code

* feat: do not show owner in PermissionManage view

* chore: fix style

* fix: icon remove fill

* feat: adjust the codes

---------

Co-authored-by: Archer <545436317@qq.com>

* perf: permission modal

* lock

---------

Co-authored-by: Finley Ge <32237950+FinleyGe@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants