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
9f4aa316
authored
Oct 30, 2024
by
Finley Ge
Committed by
GitHub
Oct 30, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: app/dataset auth (#3021)
parent
8e4084f7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
57 deletions
+38
-57
projects/app/src/pages/api/core/app/list.ts
+18
-26
projects/app/src/pages/api/core/dataset/list.ts
+20
-31
No files found.
projects/app/src/pages/api/core/app/list.ts
View file @
9f4aa316
...
...
@@ -120,47 +120,39 @@ async function handler(req: ApiRequestProps<ListAppBody>): Promise<AppListItemTy
const
filterApps
=
myApps
.
map
((
app
)
=>
{
const
{
Per
,
privateApp
}
=
(()
=>
{
// Inherit app
if
(
app
.
inheritPermission
&&
ParentApp
&&
!
AppFolderTypeList
.
includes
(
app
.
type
))
{
const
tmbPer
=
perList
.
find
(
(
item
)
=>
String
(
item
.
resourceId
)
===
String
(
ParentApp
.
_id
)
&&
!!
item
.
tmbId
const
myPerList
=
perList
.
filter
(
(
item
)
=>
String
(
item
.
tmbId
)
===
String
(
tmbId
)
||
myGroupIds
.
includes
(
String
(
item
.
groupId
))
);
const
getPer
=
(
id
:
string
)
=>
{
const
tmbPer
=
myPerList
.
find
(
(
item
)
=>
String
(
item
.
resourceId
)
===
id
&&
!!
item
.
tmbId
)?.
permission
;
const
groupPer
=
getGroupPer
(
p
erList
myP
erList
.
filter
(
(
item
)
=>
String
(
item
.
resourceId
)
===
String
(
ParentApp
.
_id
)
&&
myGroupIds
.
includes
(
String
(
item
.
groupId
))
String
(
item
.
resourceId
)
===
id
&&
myGroupIds
.
includes
(
String
(
item
.
groupId
))
)
.
map
((
item
)
=>
item
.
permission
)
);
const
clbCount
=
perList
.
filter
((
item
)
=>
String
(
item
.
resourceId
)
===
id
).
length
;
return
{
Per
:
new
AppPermission
({
per
:
tmbPer
??
groupPer
??
AppDefaultPermissionVal
,
isOwner
:
String
(
app
.
tmbId
)
===
String
(
tmbId
)
||
myPer
.
isOwner
}),
privateApp
:
perList
.
filter
((
item
)
=>
String
(
item
.
resourceId
)
===
String
(
app
.
_id
)).
length
<=
1
privateApp
:
AppFolderTypeList
.
includes
(
app
.
type
)
?
clbCount
<=
1
:
clbCount
===
0
};
};
// Inherit app
if
(
app
.
inheritPermission
&&
ParentApp
&&
!
AppFolderTypeList
.
includes
(
app
.
type
))
{
return
getPer
(
String
(
ParentApp
.
_id
));
}
else
{
const
tmbPer
=
perList
.
find
(
(
item
)
=>
String
(
item
.
resourceId
)
===
String
(
app
.
_id
)
&&
!!
item
.
tmbId
)?.
permission
;
const
group
=
perList
.
filter
(
(
item
)
=>
String
(
item
.
resourceId
)
===
String
(
app
.
_id
)
&&
myGroupIds
.
includes
(
String
(
item
.
groupId
))
);
const
groupPer
=
getGroupPer
(
group
.
map
((
item
)
=>
item
.
permission
));
return
{
Per
:
new
AppPermission
({
per
:
tmbPer
??
groupPer
??
AppDefaultPermissionVal
,
isOwner
:
String
(
app
.
tmbId
)
===
String
(
tmbId
)
||
myPer
.
isOwner
}),
privateApp
:
perList
.
filter
((
item
)
=>
String
(
item
.
resourceId
)
===
String
(
app
.
_id
)).
length
<=
1
};
return
getPer
(
String
(
app
.
_id
));
}
})();
...
...
projects/app/src/pages/api/core/dataset/list.ts
View file @
9f4aa316
...
...
@@ -103,50 +103,39 @@ async function handler(req: ApiRequestProps<GetDatasetListBody>) {
const
filterDatasets
=
myDatasets
.
map
((
dataset
)
=>
{
const
{
Per
,
privateDataset
}
=
(()
=>
{
// inherit
if
(
dataset
.
inheritPermission
&&
parentDataset
&&
dataset
.
type
!==
DatasetTypeEnum
.
folder
)
{
const
tmbPer
=
perList
.
find
(
(
item
)
=>
String
(
item
.
resourceId
)
===
String
(
parentDataset
.
_id
)
&&
!!
item
.
tmbId
const
myPerList
=
perList
.
filter
(
(
item
)
=>
String
(
item
.
tmbId
)
===
String
(
tmbId
)
||
myGroupIds
.
includes
(
String
(
item
.
groupId
))
);
const
getPer
=
(
id
:
string
)
=>
{
const
tmbPer
=
myPerList
.
find
(
(
item
)
=>
String
(
item
.
resourceId
)
===
id
&&
!!
item
.
tmbId
)?.
permission
;
const
groupPer
=
getGroupPer
(
p
erList
myP
erList
.
filter
(
(
item
)
=>
String
(
item
.
resourceId
)
===
String
(
parentDataset
.
_id
)
&&
myGroupIds
.
includes
(
String
(
item
.
groupId
))
String
(
item
.
resourceId
)
===
id
&&
myGroupIds
.
includes
(
String
(
item
.
groupId
))
)
.
map
((
item
)
=>
item
.
permission
)
);
const
clbCount
=
perList
.
filter
((
item
)
=>
String
(
item
.
resourceId
)
===
id
).
length
;
return
{
Per
:
new
DatasetPermission
({
per
:
tmbPer
??
groupPer
??
DatasetDefaultPermissionVal
,
isOwner
:
String
(
parentDataset
.
tmbId
)
===
tmbId
||
myPer
.
isOwner
isOwner
:
String
(
dataset
.
tmbId
)
===
String
(
tmbId
)
||
myPer
.
isOwner
}),
privateDataset
:
perList
.
filter
((
item
)
=>
String
(
item
.
resourceId
)
===
String
(
dataset
.
_id
)).
length
<=
1
privateDataset
:
dataset
.
type
===
'folder'
?
clbCount
<=
1
:
clbCount
===
0
};
};
// inherit
if
(
dataset
.
inheritPermission
&&
parentDataset
&&
dataset
.
type
!==
DatasetTypeEnum
.
folder
)
{
return
getPer
(
String
(
parentDataset
.
_id
));
}
else
{
const
tmbPer
=
perList
.
find
(
(
item
)
=>
String
(
item
.
resourceId
)
===
String
(
dataset
.
_id
)
&&
!!
item
.
tmbId
&&
!!
item
.
permission
)?.
permission
;
const
groupPer
=
getGroupPer
(
perList
.
filter
(
(
item
)
=>
String
(
item
.
resourceId
)
===
String
(
dataset
.
_id
)
&&
myGroupIds
.
includes
(
String
(
item
.
groupId
))
)
.
map
((
item
)
=>
item
.
permission
)
);
return
{
Per
:
new
DatasetPermission
({
per
:
tmbPer
??
groupPer
??
DatasetDefaultPermissionVal
,
isOwner
:
String
(
dataset
.
tmbId
)
===
tmbId
||
myPer
.
isOwner
}),
privateDataset
:
perList
.
filter
((
item
)
=>
String
(
item
.
resourceId
)
===
String
(
dataset
.
_id
)).
length
<=
1
};
return
getPer
(
String
(
dataset
.
_id
));
}
})();
...
...
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