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
49e23ee6
authored
May 16, 2023
by
JustSong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: fix token quota not updated
parent
c1754f77
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 additions
and
4 deletions
+1
-4
controller/token.go
+1
-4
No files found.
controller/token.go
View file @
49e23ee6
...
...
@@ -160,7 +160,6 @@ func DeleteToken(c *gin.Context) {
}
func
UpdateToken
(
c
*
gin
.
Context
)
{
isAdmin
:=
c
.
GetInt
(
"role"
)
>=
common
.
RoleAdminUser
userId
:=
c
.
GetInt
(
"id"
)
statusOnly
:=
c
.
Query
(
"status_only"
)
token
:=
model
.
Token
{}
...
...
@@ -191,7 +190,7 @@ func UpdateToken(c *gin.Context) {
if
cleanToken
.
Status
==
common
.
TokenStatusExhausted
&&
cleanToken
.
RemainQuota
<=
0
&&
!
cleanToken
.
UnlimitedQuota
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"success"
:
false
,
"message"
:
"令牌可用
次数已用尽,无法启用,请先修改令牌剩余次数,或者设置为无限次数
"
,
"message"
:
"令牌可用
额度已用尽,无法启用,请先修改令牌剩余额度,或者设置为无限额度
"
,
})
return
}
...
...
@@ -202,11 +201,9 @@ func UpdateToken(c *gin.Context) {
// If you add more fields, please also update token.Update()
cleanToken
.
Name
=
token
.
Name
cleanToken
.
ExpiredTime
=
token
.
ExpiredTime
if
isAdmin
{
cleanToken
.
RemainQuota
=
token
.
RemainQuota
cleanToken
.
UnlimitedQuota
=
token
.
UnlimitedQuota
}
}
err
=
cleanToken
.
Update
()
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
...
...
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