mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Use db.Find instead of writing methods for every object (#28084)
For those simple objects, it's unnecessary to write the find and count methods again and again.
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"sort"
|
||||
|
||||
auth_model "code.gitea.io/gitea/models/auth"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/base"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
@@ -68,14 +69,17 @@ func loadSecurityData(ctx *context.Context) {
|
||||
}
|
||||
ctx.Data["WebAuthnCredentials"] = credentials
|
||||
|
||||
tokens, err := auth_model.ListAccessTokens(ctx, auth_model.ListAccessTokensOptions{UserID: ctx.Doer.ID})
|
||||
tokens, err := db.Find[auth_model.AccessToken](ctx, auth_model.ListAccessTokensOptions{UserID: ctx.Doer.ID})
|
||||
if err != nil {
|
||||
ctx.ServerError("ListAccessTokens", err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Tokens"] = tokens
|
||||
|
||||
accountLinks, err := user_model.ListAccountLinks(ctx, ctx.Doer)
|
||||
accountLinks, err := db.Find[user_model.ExternalLoginUser](ctx, user_model.FindExternalUserOptions{
|
||||
UserID: ctx.Doer.ID,
|
||||
OrderBy: "login_source_id DESC",
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("ListAccountLinks", err)
|
||||
return
|
||||
@@ -107,7 +111,7 @@ func loadSecurityData(ctx *context.Context) {
|
||||
}
|
||||
ctx.Data["AccountLinks"] = sources
|
||||
|
||||
authSources, err := auth_model.FindSources(ctx, auth_model.FindSourcesOptions{
|
||||
authSources, err := db.Find[auth_model.Source](ctx, auth_model.FindSourcesOptions{
|
||||
IsActive: util.OptionalBoolNone,
|
||||
LoginType: auth_model.OAuth2,
|
||||
})
|
||||
|
Reference in New Issue
Block a user