Allow Access Tokens with Required Login (#611)

This commit is contained in:
Thomas Miceli
2026-02-02 19:31:07 +08:00
committed by GitHub
parent b7278b60ab
commit b7dbdde66b
2 changed files with 90 additions and 1 deletions

View File

@@ -206,6 +206,9 @@ func makeCheckRequireLogin(isSingleGistAccess bool) Middleware {
return next(ctx)
}
if getUserByToken(ctx) != nil {
return next(ctx)
}
allow, err := auth.ShouldAllowUnauthenticatedGistAccess(handlers.ContextAuthInfo{Context: ctx}, isSingleGistAccess)
if err != nil {
log.Fatal().Err(err).Msg("Failed to check if unauthenticated access is allowed")
@@ -354,7 +357,6 @@ func getUserByToken(ctx *context.Context) *db.User {
return nil
}
// Update last used timestamp
_ = accessToken.UpdateLastUsed()
return &accessToken.User