Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
efc4e860
authored
Oct 29, 2024
by
Finley Ge
Committed by
GitHub
Oct 29, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix/group (#3012)
* fix: app/dataset list private resource bug * fix: auth owner
parent
e06d72e8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
25 deletions
+32
-25
packages/service/support/permission/app/auth.ts
+6
-0
packages/service/support/permission/dataset/auth.ts
+5
-0
projects/app/src/pages/api/core/app/list.ts
+11
-13
projects/app/src/pages/api/core/dataset/list.ts
+10
-12
No files found.
packages/service/support/permission/app/auth.ts
View file @
efc4e860
...
@@ -72,6 +72,12 @@ export const authAppByTmbId = async ({
...
@@ -72,6 +72,12 @@ export const authAppByTmbId = async ({
const
isOwner
=
tmbPer
.
isOwner
||
String
(
app
.
tmbId
)
===
String
(
tmbId
);
const
isOwner
=
tmbPer
.
isOwner
||
String
(
app
.
tmbId
)
===
String
(
tmbId
);
const
{
Per
}
=
await
(
async
()
=>
{
const
{
Per
}
=
await
(
async
()
=>
{
if
(
isOwner
)
{
return
{
Per
:
new
AppPermission
({
isOwner
:
true
})
};
}
if
(
if
(
AppFolderTypeList
.
includes
(
app
.
type
)
||
AppFolderTypeList
.
includes
(
app
.
type
)
||
app
.
inheritPermission
===
false
||
app
.
inheritPermission
===
false
||
...
...
packages/service/support/permission/dataset/auth.ts
View file @
efc4e860
...
@@ -64,6 +64,11 @@ export const authDatasetByTmbId = async ({
...
@@ -64,6 +64,11 @@ export const authDatasetByTmbId = async ({
// get dataset permission or inherit permission from parent folder.
// get dataset permission or inherit permission from parent folder.
const
{
Per
}
=
await
(
async
()
=>
{
const
{
Per
}
=
await
(
async
()
=>
{
if
(
isOwner
)
{
return
{
Per
:
new
DatasetPermission
({
isOwner
:
true
})
};
}
if
(
if
(
dataset
.
type
===
DatasetTypeEnum
.
folder
||
dataset
.
type
===
DatasetTypeEnum
.
folder
||
dataset
.
inheritPermission
===
false
||
dataset
.
inheritPermission
===
false
||
...
...
projects/app/src/pages/api/core/app/list.ts
View file @
efc4e860
...
@@ -107,16 +107,11 @@ async function handler(req: ApiRequestProps<ListAppBody>): Promise<AppListItemTy
...
@@ -107,16 +107,11 @@ async function handler(req: ApiRequestProps<ListAppBody>): Promise<AppListItemTy
.
limit
(
searchKey
?
20
:
1000
)
.
limit
(
searchKey
?
20
:
1000
)
.
lean
(),
.
lean
(),
MongoResourcePermission
.
find
({
MongoResourcePermission
.
find
({
$and
:
[
resourceType
:
PerResourceTypeEnum
.
app
,
{
teamId
,
resourceType
:
PerResourceTypeEnum
.
app
,
resourceId
:
{
teamId
,
$exists
:
true
resourceId
:
{
}
$exists
:
true
}
},
{
$or
:
[{
tmbId
},
{
groupId
:
{
$in
:
myGroupIds
}
}]
}
]
}).
lean
()
}).
lean
()
]);
]);
...
@@ -143,7 +138,8 @@ async function handler(req: ApiRequestProps<ListAppBody>): Promise<AppListItemTy
...
@@ -143,7 +138,8 @@ async function handler(req: ApiRequestProps<ListAppBody>): Promise<AppListItemTy
per
:
tmbPer
??
groupPer
??
AppDefaultPermissionVal
,
per
:
tmbPer
??
groupPer
??
AppDefaultPermissionVal
,
isOwner
:
String
(
app
.
tmbId
)
===
String
(
tmbId
)
||
myPer
.
isOwner
isOwner
:
String
(
app
.
tmbId
)
===
String
(
tmbId
)
||
myPer
.
isOwner
}),
}),
privateApp
:
!
tmbPer
&&
!
groupPer
privateApp
:
perList
.
filter
((
item
)
=>
String
(
item
.
resourceId
)
===
String
(
app
.
_id
)).
length
<=
1
};
};
}
else
{
}
else
{
const
tmbPer
=
perList
.
find
(
const
tmbPer
=
perList
.
find
(
...
@@ -160,14 +156,16 @@ async function handler(req: ApiRequestProps<ListAppBody>): Promise<AppListItemTy
...
@@ -160,14 +156,16 @@ async function handler(req: ApiRequestProps<ListAppBody>): Promise<AppListItemTy
per
:
tmbPer
??
groupPer
??
AppDefaultPermissionVal
,
per
:
tmbPer
??
groupPer
??
AppDefaultPermissionVal
,
isOwner
:
String
(
app
.
tmbId
)
===
String
(
tmbId
)
||
myPer
.
isOwner
isOwner
:
String
(
app
.
tmbId
)
===
String
(
tmbId
)
||
myPer
.
isOwner
}),
}),
privateApp
:
!
tmbPer
&&
!
groupPer
privateApp
:
perList
.
filter
((
item
)
=>
String
(
item
.
resourceId
)
===
String
(
app
.
_id
)).
length
<=
1
};
};
}
}
})();
})();
return
{
return
{
...
app
,
...
app
,
permission
:
Per
,
permission
:
Per
,
privateApp
:
privateApp
privateApp
};
};
})
})
.
filter
((
app
)
=>
app
.
permission
.
hasReadPer
);
.
filter
((
app
)
=>
app
.
permission
.
hasReadPer
);
...
...
projects/app/src/pages/api/core/dataset/list.ts
View file @
efc4e860
...
@@ -92,16 +92,11 @@ async function handler(req: ApiRequestProps<GetDatasetListBody>) {
...
@@ -92,16 +92,11 @@ async function handler(req: ApiRequestProps<GetDatasetListBody>) {
})
})
.
lean
(),
.
lean
(),
MongoResourcePermission
.
find
({
MongoResourcePermission
.
find
({
$and
:
[
resourceType
:
PerResourceTypeEnum
.
dataset
,
{
teamId
,
resourceType
:
PerResourceTypeEnum
.
dataset
,
resourceId
:
{
teamId
,
$exists
:
true
resourceId
:
{
}
$exists
:
true
}
},
{
$or
:
[{
tmbId
},
{
groupId
:
{
$in
:
myGroupIds
}
}]
}
]
}).
lean
()
}).
lean
()
]);
]);
...
@@ -127,7 +122,8 @@ async function handler(req: ApiRequestProps<GetDatasetListBody>) {
...
@@ -127,7 +122,8 @@ async function handler(req: ApiRequestProps<GetDatasetListBody>) {
per
:
tmbPer
??
groupPer
??
DatasetDefaultPermissionVal
,
per
:
tmbPer
??
groupPer
??
DatasetDefaultPermissionVal
,
isOwner
:
String
(
parentDataset
.
tmbId
)
===
tmbId
||
myPer
.
isOwner
isOwner
:
String
(
parentDataset
.
tmbId
)
===
tmbId
||
myPer
.
isOwner
}),
}),
privateDataset
:
!
tmbPer
&&
!
groupPer
privateDataset
:
perList
.
filter
((
item
)
=>
String
(
item
.
resourceId
)
===
String
(
dataset
.
_id
)).
length
<=
1
};
};
}
else
{
}
else
{
const
tmbPer
=
perList
.
find
(
const
tmbPer
=
perList
.
find
(
...
@@ -148,10 +144,12 @@ async function handler(req: ApiRequestProps<GetDatasetListBody>) {
...
@@ -148,10 +144,12 @@ async function handler(req: ApiRequestProps<GetDatasetListBody>) {
per
:
tmbPer
??
groupPer
??
DatasetDefaultPermissionVal
,
per
:
tmbPer
??
groupPer
??
DatasetDefaultPermissionVal
,
isOwner
:
String
(
dataset
.
tmbId
)
===
tmbId
||
myPer
.
isOwner
isOwner
:
String
(
dataset
.
tmbId
)
===
tmbId
||
myPer
.
isOwner
}),
}),
privateDataset
:
!
tmbPer
&&
!
groupPer
privateDataset
:
perList
.
filter
((
item
)
=>
String
(
item
.
resourceId
)
===
String
(
dataset
.
_id
)).
length
<=
1
};
};
}
}
})();
})();
return
{
return
{
...
dataset
,
...
dataset
,
permission
:
Per
,
permission
:
Per
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment