summaryrefslogtreecommitdiff
path: root/internal/middleware/tokencheck.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2023-08-10 15:08:41 +0100
committerLibravatar GitHub <noreply@github.com>2023-08-10 15:08:41 +0100
commit91cbcd589e7c4ab87e5994e4d0276ea1248dc5c2 (patch)
treea6b12c30168eb5fed4267dcb6a1f385b86afdcdf /internal/middleware/tokencheck.go
parent[feature] List replies policy, refactor async workers (#2087) (diff)
downloadgotosocial-91cbcd589e7c4ab87e5994e4d0276ea1248dc5c2.tar.xz
[performance] remove last of relational queries to instead rely on caches (#2091)
Diffstat (limited to 'internal/middleware/tokencheck.go')
-rw-r--r--internal/middleware/tokencheck.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/internal/middleware/tokencheck.go b/internal/middleware/tokencheck.go
index 1496363af..d2570c3f0 100644
--- a/internal/middleware/tokencheck.go
+++ b/internal/middleware/tokencheck.go
@@ -22,7 +22,6 @@ import (
"github.com/gin-gonic/gin"
"github.com/superseriousbusiness/gotosocial/internal/db"
- "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/log"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
"github.com/superseriousbusiness/oauth2/v4"
@@ -125,8 +124,8 @@ func TokenCheck(dbConn db.DB, validateBearerToken func(r *http.Request) (oauth2.
log.Tracef(ctx, "authenticated client %s with bearer token, scope is %s", clientID, ti.GetScope())
// fetch app for this token
- app := &gtsmodel.Application{}
- if err := dbConn.GetWhere(ctx, []db.Where{{Key: "client_id", Value: clientID}}, app); err != nil {
+ app, err := dbConn.GetApplicationByClientID(ctx, clientID)
+ if err != nil {
if err != db.ErrNoEntries {
log.Errorf(ctx, "database error looking for application with clientID %s: %s", clientID, err)
return
@@ -134,6 +133,7 @@ func TokenCheck(dbConn db.DB, validateBearerToken func(r *http.Request) (oauth2.
log.Warnf(ctx, "no app found for client %s", clientID)
return
}
+
c.Set(oauth.SessionAuthorizedApplication, app)
}
}