Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
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
Commit
917aa6c0
authored
Oct 10, 2024
by
1808837298@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: playground group
parent
f731c755
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletions
+12
-1
common/user_groups.go
+5
-0
controller/relay.go
+7
-1
No files found.
common/user_groups.go
View file @
917aa6c0
...
@@ -21,3 +21,8 @@ func UpdateUserUsableGroupsByJSONString(jsonStr string) error {
...
@@ -21,3 +21,8 @@ func UpdateUserUsableGroupsByJSONString(jsonStr string) error {
UserUsableGroups
=
make
(
map
[
string
]
string
)
UserUsableGroups
=
make
(
map
[
string
]
string
)
return
json
.
Unmarshal
([]
byte
(
jsonStr
),
&
UserUsableGroups
)
return
json
.
Unmarshal
([]
byte
(
jsonStr
),
&
UserUsableGroups
)
}
}
func
GroupInUserUsableGroups
(
groupName
string
)
bool
{
_
,
ok
:=
UserUsableGroups
[
groupName
]
return
ok
}
controller/relay.go
View file @
917aa6c0
...
@@ -68,9 +68,15 @@ func Playground(c *gin.Context) {
...
@@ -68,9 +68,15 @@ func Playground(c *gin.Context) {
}
}
c
.
Set
(
"original_model"
,
playgroundRequest
.
Model
)
c
.
Set
(
"original_model"
,
playgroundRequest
.
Model
)
group
:=
playgroundRequest
.
Group
group
:=
playgroundRequest
.
Group
userGroup
:=
c
.
GetString
(
"group"
)
if
group
==
""
{
if
group
==
""
{
group
=
c
.
GetString
(
"group"
)
group
=
userGroup
}
else
{
}
else
{
if
!
common
.
GroupInUserUsableGroups
(
group
)
&&
group
!=
userGroup
{
openaiErr
=
service
.
OpenAIErrorWrapperLocal
(
errors
.
New
(
"无权访问该分组"
),
"group_not_allowed"
,
http
.
StatusForbidden
)
return
}
c
.
Set
(
"group"
,
group
)
c
.
Set
(
"group"
,
group
)
}
}
c
.
Set
(
"token_name"
,
"playground-"
+
group
)
c
.
Set
(
"token_name"
,
"playground-"
+
group
)
...
...
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