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
Unverified
Commit
0d5995eb
authored
Jul 05, 2026
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(auth): allow read-only access for non-disabled tokens
parent
5fc35e28
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
middleware/auth.go
+11
-0
No files found.
middleware/auth.go
View file @
0d5995eb
...
@@ -274,6 +274,17 @@ func TokenAuthReadOnly() func(c *gin.Context) {
...
@@ -274,6 +274,17 @@ func TokenAuthReadOnly() func(c *gin.Context) {
return
return
}
}
// TokenAuthReadOnly must keep allowing other token states to query read-only
// data, such as token usage logs; only explicitly disabled tokens are denied.
if
token
.
Status
==
common
.
TokenStatusDisabled
{
c
.
JSON
(
http
.
StatusUnauthorized
,
gin
.
H
{
"success"
:
false
,
"message"
:
common
.
TranslateMessage
(
c
,
i18n
.
MsgTokenStatusUnavailable
),
})
c
.
Abort
()
return
}
userCache
,
err
:=
model
.
GetUserCache
(
token
.
UserId
)
userCache
,
err
:=
model
.
GetUserCache
(
token
.
UserId
)
if
err
!=
nil
{
if
err
!=
nil
{
common
.
SysLog
(
fmt
.
Sprintf
(
"TokenAuthReadOnly GetUserCache error for user %d: %v"
,
token
.
UserId
,
err
))
common
.
SysLog
(
fmt
.
Sprintf
(
"TokenAuthReadOnly GetUserCache error for user %d: %v"
,
token
.
UserId
,
err
))
...
...
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