refactor: api token scope check (#38862)

"ApiTokenScope" already means "IsApiToken=true".

All "IsApiToken" should be removed.

---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
wxiaoguang
2026-08-11 15:37:44 +08:00
committed by GitHub
parent 7e3eeca779
commit b3f547ac16
12 changed files with 19 additions and 47 deletions
+1 -3
View File
@@ -81,7 +81,6 @@ func (b *Basic) VerifyAuthToken(req *http.Request, w http.ResponseWriter, store
}
store.GetData()["LoginMethod"] = OAuth2TokenMethodName
store.GetData()["IsApiToken"] = true
store.GetData()["ApiTokenScope"] = accessTokenScope
return u, nil
}
@@ -102,7 +101,6 @@ func (b *Basic) VerifyAuthToken(req *http.Request, w http.ResponseWriter, store
}
store.GetData()["LoginMethod"] = AccessTokenMethodName
store.GetData()["IsApiToken"] = true
store.GetData()["ApiTokenScope"] = token.Scope
return u, nil
} else if !errors.Is(err, util.ErrNotExist) {
@@ -187,7 +185,7 @@ func validateTOTP(req *http.Request, u *user_model.User) error {
}
func GetAccessScope(store DataStore) auth_model.AccessTokenScope {
if scope, ok := store.GetData()["ApiTokenScope"].(auth_model.AccessTokenScope); ok {
if scope, hasApiTokenScope := store.GetData()["ApiTokenScope"].(auth_model.AccessTokenScope); hasApiTokenScope {
return scope
}
switch store.GetData()["LoginMethod"] {