summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorJakobDev <jakobdev@gmx.de>2023-09-15 08:13:19 +0200
committerGitHub <noreply@github.com>2023-09-15 06:13:19 +0000
commitc548dde205244a39a26ba98377c0f5cc11da7041 (patch)
treef9d9e1185609703e320ed07fd2ff3f95dbdcc230 /routers
parentf8a109440655b77e8554e1744e31bf52a7c63df7 (diff)
downloadgitea-c548dde205244a39a26ba98377c0f5cc11da7041.tar.gz
gitea-c548dde205244a39a26ba98377c0f5cc11da7041.zip
More refactoring of `db.DefaultContext` (#27083)
Next step of #27065
Diffstat (limited to 'routers')
-rw-r--r--routers/api/packages/alpine/alpine.go2
-rw-r--r--routers/api/packages/chef/auth.go7
-rw-r--r--routers/api/packages/debian/debian.go2
-rw-r--r--routers/api/packages/nuget/auth.go4
-rw-r--r--routers/api/packages/rpm/rpm.go2
-rw-r--r--routers/api/v1/activitypub/person.go2
-rw-r--r--routers/api/v1/api.go2
-rw-r--r--routers/api/v1/org/team.go2
-rw-r--r--routers/api/v1/repo/issue_attachment.go4
-rw-r--r--routers/api/v1/repo/issue_comment_attachment.go2
-rw-r--r--routers/api/v1/repo/pull.go2
-rw-r--r--routers/api/v1/repo/release_attachment.go2
-rw-r--r--routers/api/v1/repo/star.go2
-rw-r--r--routers/api/v1/repo/subscriber.go2
-rw-r--r--routers/api/v1/repo/teams.go6
-rw-r--r--routers/api/v1/user/app.go12
-rw-r--r--routers/api/v1/user/star.go4
-rw-r--r--routers/api/v1/user/watch.go2
-rw-r--r--routers/web/admin/users.go6
-rw-r--r--routers/web/auth/2fa.go8
-rw-r--r--routers/web/auth/auth.go2
-rw-r--r--routers/web/auth/linkaccount.go2
-rw-r--r--routers/web/auth/oauth.go2
-rw-r--r--routers/web/auth/password.go6
-rw-r--r--routers/web/org/teams.go2
-rw-r--r--routers/web/repo/attachment.go4
-rw-r--r--routers/web/repo/editor.go4
-rw-r--r--routers/web/repo/http.go2
-rw-r--r--routers/web/repo/issue.go6
-rw-r--r--routers/web/repo/middlewares.go8
-rw-r--r--routers/web/repo/repo.go4
-rw-r--r--routers/web/repo/setting/collaboration.go2
-rw-r--r--routers/web/repo/setting/settings_test.go9
-rw-r--r--routers/web/repo/view.go4
-rw-r--r--routers/web/shared/user/header.go2
-rw-r--r--routers/web/user/setting/applications.go8
-rw-r--r--routers/web/user/setting/packages.go2
-rw-r--r--routers/web/user/setting/profile.go4
-rw-r--r--routers/web/user/setting/security/2fa.go14
-rw-r--r--routers/web/user/setting/security/openid.go6
-rw-r--r--routers/web/user/setting/security/security.go6
41 files changed, 88 insertions, 86 deletions
diff --git a/routers/api/packages/alpine/alpine.go b/routers/api/packages/alpine/alpine.go
index 51a5c784e0..d499244dc3 100644
--- a/routers/api/packages/alpine/alpine.go
+++ b/routers/api/packages/alpine/alpine.go
@@ -31,7 +31,7 @@ func apiError(ctx *context.Context, status int, obj any) {
}
func GetRepositoryKey(ctx *context.Context) {
- _, pub, err := alpine_service.GetOrCreateKeyPair(ctx.Package.Owner.ID)
+ _, pub, err := alpine_service.GetOrCreateKeyPair(ctx, ctx.Package.Owner.ID)
if err != nil {
apiError(ctx, http.StatusInternalServerError, err)
return
diff --git a/routers/api/packages/chef/auth.go b/routers/api/packages/chef/auth.go
index 53055bb682..3aef8281a4 100644
--- a/routers/api/packages/chef/auth.go
+++ b/routers/api/packages/chef/auth.go
@@ -4,6 +4,7 @@
package chef
import (
+ "context"
"crypto"
"crypto/rsa"
"crypto/sha1"
@@ -63,7 +64,7 @@ func (a *Auth) Verify(req *http.Request, w http.ResponseWriter, store auth.DataS
return nil, nil
}
- pub, err := getUserPublicKey(u)
+ pub, err := getUserPublicKey(req.Context(), u)
if err != nil {
return nil, err
}
@@ -93,8 +94,8 @@ func getUserFromRequest(req *http.Request) (*user_model.User, error) {
return user_model.GetUserByName(req.Context(), username)
}
-func getUserPublicKey(u *user_model.User) (crypto.PublicKey, error) {
- pubKey, err := user_model.GetSetting(u.ID, chef_module.SettingPublicPem)
+func getUserPublicKey(ctx context.Context, u *user_model.User) (crypto.PublicKey, error) {
+ pubKey, err := user_model.GetSetting(ctx, u.ID, chef_module.SettingPublicPem)
if err != nil {
return nil, err
}
diff --git a/routers/api/packages/debian/debian.go b/routers/api/packages/debian/debian.go
index 04ca2ed977..869bc1e901 100644
--- a/routers/api/packages/debian/debian.go
+++ b/routers/api/packages/debian/debian.go
@@ -30,7 +30,7 @@ func apiError(ctx *context.Context, status int, obj any) {
}
func GetRepositoryKey(ctx *context.Context) {
- _, pub, err := debian_service.GetOrCreateKeyPair(ctx.Package.Owner.ID)
+ _, pub, err := debian_service.GetOrCreateKeyPair(ctx, ctx.Package.Owner.ID)
if err != nil {
apiError(ctx, http.StatusInternalServerError, err)
return
diff --git a/routers/api/packages/nuget/auth.go b/routers/api/packages/nuget/auth.go
index 60b81b8d4b..1bb68d059b 100644
--- a/routers/api/packages/nuget/auth.go
+++ b/routers/api/packages/nuget/auth.go
@@ -23,7 +23,7 @@ func (a *Auth) Name() string {
// https://docs.microsoft.com/en-us/nuget/api/package-publish-resource#request-parameters
func (a *Auth) Verify(req *http.Request, w http.ResponseWriter, store auth.DataStore, sess auth.SessionStore) (*user_model.User, error) {
- token, err := auth_model.GetAccessTokenBySHA(req.Header.Get("X-NuGet-ApiKey"))
+ token, err := auth_model.GetAccessTokenBySHA(req.Context(), req.Header.Get("X-NuGet-ApiKey"))
if err != nil {
if !(auth_model.IsErrAccessTokenNotExist(err) || auth_model.IsErrAccessTokenEmpty(err)) {
log.Error("GetAccessTokenBySHA: %v", err)
@@ -39,7 +39,7 @@ func (a *Auth) Verify(req *http.Request, w http.ResponseWriter, store auth.DataS
}
token.UpdatedUnix = timeutil.TimeStampNow()
- if err := auth_model.UpdateAccessToken(token); err != nil {
+ if err := auth_model.UpdateAccessToken(req.Context(), token); err != nil {
log.Error("UpdateAccessToken: %v", err)
}
diff --git a/routers/api/packages/rpm/rpm.go b/routers/api/packages/rpm/rpm.go
index 1e462bb908..65b7c74bdd 100644
--- a/routers/api/packages/rpm/rpm.go
+++ b/routers/api/packages/rpm/rpm.go
@@ -45,7 +45,7 @@ gpgkey=`+url+`/repository.key`)
// Gets or creates the PGP public key used to sign repository metadata files
func GetRepositoryKey(ctx *context.Context) {
- _, pub, err := rpm_service.GetOrCreateKeyPair(ctx.Package.Owner.ID)
+ _, pub, err := rpm_service.GetOrCreateKeyPair(ctx, ctx.Package.Owner.ID)
if err != nil {
apiError(ctx, http.StatusInternalServerError, err)
return
diff --git a/routers/api/v1/activitypub/person.go b/routers/api/v1/activitypub/person.go
index bc6b82b179..cad5032d10 100644
--- a/routers/api/v1/activitypub/person.go
+++ b/routers/api/v1/activitypub/person.go
@@ -66,7 +66,7 @@ func Person(ctx *context.APIContext) {
person.PublicKey.ID = ap.IRI(link + "#main-key")
person.PublicKey.Owner = ap.IRI(link)
- publicKeyPem, err := activitypub.GetPublicKey(ctx.ContextUser)
+ publicKeyPem, err := activitypub.GetPublicKey(ctx, ctx.ContextUser)
if err != nil {
ctx.ServerError("GetPublicKey", err)
return
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index fd7d3687ac..ca74a23a4b 100644
--- a/routers/api/v1/api.go
+++ b/routers/api/v1/api.go
@@ -776,7 +776,7 @@ func verifyAuthWithOptions(options *common.VerifyOptions) func(ctx *context.APIC
if skip, ok := ctx.Data["SkipLocalTwoFA"]; ok && skip.(bool) {
return // Skip 2FA
}
- twofa, err := auth_model.GetTwoFactorByUID(ctx.Doer.ID)
+ twofa, err := auth_model.GetTwoFactorByUID(ctx, ctx.Doer.ID)
if err != nil {
if auth_model.IsErrTwoFactorNotEnrolled(err) {
return // No 2FA enrollment for this user
diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go
index 944fd763ca..519572ee51 100644
--- a/routers/api/v1/org/team.go
+++ b/routers/api/v1/org/team.go
@@ -693,7 +693,7 @@ func AddTeamRepository(ctx *context.APIContext) {
ctx.Error(http.StatusForbidden, "", "Must have admin-level access to the repository")
return
}
- if err := org_service.TeamAddRepository(ctx.Org.Team, repo); err != nil {
+ if err := org_service.TeamAddRepository(ctx, ctx.Org.Team, repo); err != nil {
ctx.Error(http.StatusInternalServerError, "TeamAddRepository", err)
return
}
diff --git a/routers/api/v1/repo/issue_attachment.go b/routers/api/v1/repo/issue_attachment.go
index c689e70a08..60e554990f 100644
--- a/routers/api/v1/repo/issue_attachment.go
+++ b/routers/api/v1/repo/issue_attachment.go
@@ -189,7 +189,7 @@ func CreateIssueAttachment(ctx *context.APIContext) {
issue.Attachments = append(issue.Attachments, attachment)
- if err := issue_service.ChangeContent(issue, ctx.Doer, issue.Content); err != nil {
+ if err := issue_service.ChangeContent(ctx, issue, ctx.Doer, issue.Content); err != nil {
ctx.Error(http.StatusInternalServerError, "ChangeContent", err)
return
}
@@ -298,7 +298,7 @@ func DeleteIssueAttachment(ctx *context.APIContext) {
return
}
- if err := repo_model.DeleteAttachment(attachment, true); err != nil {
+ if err := repo_model.DeleteAttachment(ctx, attachment, true); err != nil {
ctx.Error(http.StatusInternalServerError, "DeleteAttachment", err)
return
}
diff --git a/routers/api/v1/repo/issue_comment_attachment.go b/routers/api/v1/repo/issue_comment_attachment.go
index 121e3f10e0..c30e8278db 100644
--- a/routers/api/v1/repo/issue_comment_attachment.go
+++ b/routers/api/v1/repo/issue_comment_attachment.go
@@ -303,7 +303,7 @@ func DeleteIssueCommentAttachment(ctx *context.APIContext) {
return
}
- if err := repo_model.DeleteAttachment(attach, true); err != nil {
+ if err := repo_model.DeleteAttachment(ctx, attach, true); err != nil {
ctx.Error(http.StatusInternalServerError, "DeleteAttachment", err)
return
}
diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go
index 0fe657d245..4f22a059a1 100644
--- a/routers/api/v1/repo/pull.go
+++ b/routers/api/v1/repo/pull.go
@@ -97,7 +97,7 @@ func ListPullRequests(ctx *context.APIContext) {
listOptions := utils.GetListOptions(ctx)
- prs, maxResults, err := issues_model.PullRequests(ctx.Repo.Repository.ID, &issues_model.PullRequestsOptions{
+ prs, maxResults, err := issues_model.PullRequests(ctx, ctx.Repo.Repository.ID, &issues_model.PullRequestsOptions{
ListOptions: listOptions,
State: ctx.FormTrim("state"),
SortType: ctx.FormTrim("sort"),
diff --git a/routers/api/v1/repo/release_attachment.go b/routers/api/v1/repo/release_attachment.go
index 9571c8ebb9..e142183128 100644
--- a/routers/api/v1/repo/release_attachment.go
+++ b/routers/api/v1/repo/release_attachment.go
@@ -345,7 +345,7 @@ func DeleteReleaseAttachment(ctx *context.APIContext) {
}
// FIXME Should prove the existence of the given repo, but results in unnecessary database requests
- if err := repo_model.DeleteAttachment(attach, true); err != nil {
+ if err := repo_model.DeleteAttachment(ctx, attach, true); err != nil {
ctx.Error(http.StatusInternalServerError, "DeleteAttachment", err)
return
}
diff --git a/routers/api/v1/repo/star.go b/routers/api/v1/repo/star.go
index fccc76b518..05227e33a0 100644
--- a/routers/api/v1/repo/star.go
+++ b/routers/api/v1/repo/star.go
@@ -45,7 +45,7 @@ func ListStargazers(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- stargazers, err := repo_model.GetStargazers(ctx.Repo.Repository, utils.GetListOptions(ctx))
+ stargazers, err := repo_model.GetStargazers(ctx, ctx.Repo.Repository, utils.GetListOptions(ctx))
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetStargazers", err)
return
diff --git a/routers/api/v1/repo/subscriber.go b/routers/api/v1/repo/subscriber.go
index 61d9470707..05509fc443 100644
--- a/routers/api/v1/repo/subscriber.go
+++ b/routers/api/v1/repo/subscriber.go
@@ -45,7 +45,7 @@ func ListSubscribers(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- subscribers, err := repo_model.GetRepoWatchers(ctx.Repo.Repository.ID, utils.GetListOptions(ctx))
+ subscribers, err := repo_model.GetRepoWatchers(ctx, ctx.Repo.Repository.ID, utils.GetListOptions(ctx))
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetRepoWatchers", err)
return
diff --git a/routers/api/v1/repo/teams.go b/routers/api/v1/repo/teams.go
index 2887e89603..1bacc71211 100644
--- a/routers/api/v1/repo/teams.go
+++ b/routers/api/v1/repo/teams.go
@@ -99,7 +99,7 @@ func IsTeam(ctx *context.APIContext) {
return
}
- if repo_service.HasRepository(team, ctx.Repo.Repository.ID) {
+ if repo_service.HasRepository(ctx, team, ctx.Repo.Repository.ID) {
apiTeam, err := convert.ToTeam(ctx, team)
if err != nil {
ctx.InternalServerError(err)
@@ -198,14 +198,14 @@ func changeRepoTeam(ctx *context.APIContext, add bool) {
return
}
- repoHasTeam := repo_service.HasRepository(team, ctx.Repo.Repository.ID)
+ repoHasTeam := repo_service.HasRepository(ctx, team, ctx.Repo.Repository.ID)
var err error
if add {
if repoHasTeam {
ctx.Error(http.StatusUnprocessableEntity, "alreadyAdded", fmt.Errorf("team '%s' is already added to repo", team.Name))
return
}
- err = org_service.TeamAddRepository(team, ctx.Repo.Repository)
+ err = org_service.TeamAddRepository(ctx, team, ctx.Repo.Repository)
} else {
if !repoHasTeam {
ctx.Error(http.StatusUnprocessableEntity, "notAdded", fmt.Errorf("team '%s' was not added to repo", team.Name))
diff --git a/routers/api/v1/user/app.go b/routers/api/v1/user/app.go
index f89d53945f..e512ba9e4b 100644
--- a/routers/api/v1/user/app.go
+++ b/routers/api/v1/user/app.go
@@ -46,12 +46,12 @@ func ListAccessTokens(ctx *context.APIContext) {
opts := auth_model.ListAccessTokensOptions{UserID: ctx.Doer.ID, ListOptions: utils.GetListOptions(ctx)}
- count, err := auth_model.CountAccessTokens(opts)
+ count, err := auth_model.CountAccessTokens(ctx, opts)
if err != nil {
ctx.InternalServerError(err)
return
}
- tokens, err := auth_model.ListAccessTokens(opts)
+ tokens, err := auth_model.ListAccessTokens(ctx, opts)
if err != nil {
ctx.InternalServerError(err)
return
@@ -103,7 +103,7 @@ func CreateAccessToken(ctx *context.APIContext) {
Name: form.Name,
}
- exist, err := auth_model.AccessTokenByNameExists(t)
+ exist, err := auth_model.AccessTokenByNameExists(ctx, t)
if err != nil {
ctx.InternalServerError(err)
return
@@ -120,7 +120,7 @@ func CreateAccessToken(ctx *context.APIContext) {
}
t.Scope = scope
- if err := auth_model.NewAccessToken(t); err != nil {
+ if err := auth_model.NewAccessToken(ctx, t); err != nil {
ctx.Error(http.StatusInternalServerError, "NewAccessToken", err)
return
}
@@ -162,7 +162,7 @@ func DeleteAccessToken(ctx *context.APIContext) {
tokenID, _ := strconv.ParseInt(token, 0, 64)
if tokenID == 0 {
- tokens, err := auth_model.ListAccessTokens(auth_model.ListAccessTokensOptions{
+ tokens, err := auth_model.ListAccessTokens(ctx, auth_model.ListAccessTokensOptions{
Name: token,
UserID: ctx.Doer.ID,
})
@@ -187,7 +187,7 @@ func DeleteAccessToken(ctx *context.APIContext) {
return
}
- if err := auth_model.DeleteAccessTokenByID(tokenID, ctx.Doer.ID); err != nil {
+ if err := auth_model.DeleteAccessTokenByID(ctx, tokenID, ctx.Doer.ID); err != nil {
if auth_model.IsErrAccessTokenNotExist(err) {
ctx.NotFound()
} else {
diff --git a/routers/api/v1/user/star.go b/routers/api/v1/user/star.go
index 09f799cc6a..2659789ddd 100644
--- a/routers/api/v1/user/star.go
+++ b/routers/api/v1/user/star.go
@@ -155,7 +155,7 @@ func Star(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- err := repo_model.StarRepo(ctx.Doer.ID, ctx.Repo.Repository.ID, true)
+ err := repo_model.StarRepo(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID, true)
if err != nil {
ctx.Error(http.StatusInternalServerError, "StarRepo", err)
return
@@ -185,7 +185,7 @@ func Unstar(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- err := repo_model.StarRepo(ctx.Doer.ID, ctx.Repo.Repository.ID, false)
+ err := repo_model.StarRepo(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID, false)
if err != nil {
ctx.Error(http.StatusInternalServerError, "StarRepo", err)
return
diff --git a/routers/api/v1/user/watch.go b/routers/api/v1/user/watch.go
index b5899baa93..7f531eafaa 100644
--- a/routers/api/v1/user/watch.go
+++ b/routers/api/v1/user/watch.go
@@ -124,7 +124,7 @@ func IsWatching(ctx *context.APIContext) {
// "404":
// description: User is not watching this repo or repo do not exist
- if repo_model.IsWatching(ctx.Doer.ID, ctx.Repo.Repository.ID) {
+ if repo_model.IsWatching(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID) {
ctx.JSON(http.StatusOK, api.WatchInfo{
Subscribed: true,
Ignored: false,
diff --git a/routers/web/admin/users.go b/routers/web/admin/users.go
index 0414a60e18..5562cc390c 100644
--- a/routers/web/admin/users.go
+++ b/routers/web/admin/users.go
@@ -238,7 +238,7 @@ func prepareUserInfo(ctx *context.Context) *user_model.User {
}
ctx.Data["Sources"] = sources
- hasTOTP, err := auth.HasTwoFactorByUID(u.ID)
+ hasTOTP, err := auth.HasTwoFactorByUID(ctx, u.ID)
if err != nil {
ctx.ServerError("auth.HasTwoFactorByUID", err)
return nil
@@ -410,12 +410,12 @@ func EditUserPost(ctx *context.Context) {
}
if form.Reset2FA {
- tf, err := auth.GetTwoFactorByUID(u.ID)
+ tf, err := auth.GetTwoFactorByUID(ctx, u.ID)
if err != nil && !auth.IsErrTwoFactorNotEnrolled(err) {
ctx.ServerError("auth.GetTwoFactorByUID", err)
return
} else if tf != nil {
- if err := auth.DeleteTwoFactorByID(tf.ID, u.ID); err != nil {
+ if err := auth.DeleteTwoFactorByID(ctx, tf.ID, u.ID); err != nil {
ctx.ServerError("auth.DeleteTwoFactorByID", err)
return
}
diff --git a/routers/web/auth/2fa.go b/routers/web/auth/2fa.go
index 4791b04313..31ede82f01 100644
--- a/routers/web/auth/2fa.go
+++ b/routers/web/auth/2fa.go
@@ -53,7 +53,7 @@ func TwoFactorPost(ctx *context.Context) {
}
id := idSess.(int64)
- twofa, err := auth.GetTwoFactorByUID(id)
+ twofa, err := auth.GetTwoFactorByUID(ctx, id)
if err != nil {
ctx.ServerError("UserSignIn", err)
return
@@ -83,7 +83,7 @@ func TwoFactorPost(ctx *context.Context) {
}
twofa.LastUsedPasscode = form.Passcode
- if err = auth.UpdateTwoFactor(twofa); err != nil {
+ if err = auth.UpdateTwoFactor(ctx, twofa); err != nil {
ctx.ServerError("UserSignIn", err)
return
}
@@ -126,7 +126,7 @@ func TwoFactorScratchPost(ctx *context.Context) {
}
id := idSess.(int64)
- twofa, err := auth.GetTwoFactorByUID(id)
+ twofa, err := auth.GetTwoFactorByUID(ctx, id)
if err != nil {
ctx.ServerError("UserSignIn", err)
return
@@ -140,7 +140,7 @@ func TwoFactorScratchPost(ctx *context.Context) {
ctx.ServerError("UserSignIn", err)
return
}
- if err = auth.UpdateTwoFactor(twofa); err != nil {
+ if err = auth.UpdateTwoFactor(ctx, twofa); err != nil {
ctx.ServerError("UserSignIn", err)
return
}
diff --git a/routers/web/auth/auth.go b/routers/web/auth/auth.go
index f8549f68f6..b7a73e4379 100644
--- a/routers/web/auth/auth.go
+++ b/routers/web/auth/auth.go
@@ -236,7 +236,7 @@ func SignInPost(ctx *context.Context) {
// If this user is enrolled in 2FA TOTP, we can't sign the user in just yet.
// Instead, redirect them to the 2FA authentication page.
- hasTOTPtwofa, err := auth.HasTwoFactorByUID(u.ID)
+ hasTOTPtwofa, err := auth.HasTwoFactorByUID(ctx, u.ID)
if err != nil {
ctx.ServerError("UserSignIn", err)
return
diff --git a/routers/web/auth/linkaccount.go b/routers/web/auth/linkaccount.go
index e6791cafce..745b4e818c 100644
--- a/routers/web/auth/linkaccount.go
+++ b/routers/web/auth/linkaccount.go
@@ -157,7 +157,7 @@ func linkAccount(ctx *context.Context, u *user_model.User, gothUser goth.User, r
// If this user is enrolled in 2FA, we can't sign the user in just yet.
// Instead, redirect them to the 2FA authentication page.
// We deliberately ignore the skip local 2fa setting here because we are linking to a previous user here
- _, err := auth.GetTwoFactorByUID(u.ID)
+ _, err := auth.GetTwoFactorByUID(ctx, u.ID)
if err != nil {
if !auth.IsErrTwoFactorNotEnrolled(err) {
ctx.ServerError("UserLinkAccount", err)
diff --git a/routers/web/auth/oauth.go b/routers/web/auth/oauth.go
index 178ae84366..640c01e203 100644
--- a/routers/web/auth/oauth.go
+++ b/routers/web/auth/oauth.go
@@ -1097,7 +1097,7 @@ func handleOAuth2SignIn(ctx *context.Context, source *auth.Source, u *user_model
needs2FA := false
if !source.Cfg.(*oauth2.Source).SkipLocalTwoFA {
- _, err := auth.GetTwoFactorByUID(u.ID)
+ _, err := auth.GetTwoFactorByUID(ctx, u.ID)
if err != nil && !auth.IsErrTwoFactorNotEnrolled(err) {
ctx.ServerError("UserSignIn", err)
return
diff --git a/routers/web/auth/password.go b/routers/web/auth/password.go
index 970d316300..bdfa8c4025 100644
--- a/routers/web/auth/password.go
+++ b/routers/web/auth/password.go
@@ -120,7 +120,7 @@ func commonResetPassword(ctx *context.Context) (*user_model.User, *auth.TwoFacto
return nil, nil
}
- twofa, err := auth.GetTwoFactorByUID(u.ID)
+ twofa, err := auth.GetTwoFactorByUID(ctx, u.ID)
if err != nil {
if !auth.IsErrTwoFactorNotEnrolled(err) {
ctx.Error(http.StatusInternalServerError, "CommonResetPassword", err.Error())
@@ -217,7 +217,7 @@ func ResetPasswdPost(ctx *context.Context) {
}
twofa.LastUsedPasscode = passcode
- if err = auth.UpdateTwoFactor(twofa); err != nil {
+ if err = auth.UpdateTwoFactor(ctx, twofa); err != nil {
ctx.ServerError("ResetPasswdPost: UpdateTwoFactor", err)
return
}
@@ -249,7 +249,7 @@ func ResetPasswdPost(ctx *context.Context) {
ctx.ServerError("UserSignIn", err)
return
}
- if err = auth.UpdateTwoFactor(twofa); err != nil {
+ if err = auth.UpdateTwoFactor(ctx, twofa); err != nil {
ctx.ServerError("UserSignIn", err)
return
}
diff --git a/routers/web/org/teams.go b/routers/web/org/teams.go
index 46ca68b612..dfb87b28f8 100644
--- a/routers/web/org/teams.go
+++ b/routers/web/org/teams.go
@@ -247,7 +247,7 @@ func TeamsRepoAction(ctx *context.Context) {
ctx.ServerError("GetRepositoryByName", err)
return
}
- err = org_service.TeamAddRepository(ctx.Org.Team, repo)
+ err = org_service.TeamAddRepository(ctx, ctx.Org.Team, repo)
case "remove":
err = repo_service.RemoveRepositoryFromTeam(ctx, ctx.Org.Team, ctx.FormInt64("repoid"))
case "addall":
diff --git a/routers/web/repo/attachment.go b/routers/web/repo/attachment.go
index b7be77914f..7b7fa9e994 100644
--- a/routers/web/repo/attachment.go
+++ b/routers/web/repo/attachment.go
@@ -77,7 +77,7 @@ func DeleteAttachment(ctx *context.Context) {
ctx.Error(http.StatusForbidden)
return
}
- err = repo_model.DeleteAttachment(attach, true)
+ err = repo_model.DeleteAttachment(ctx, attach, true)
if err != nil {
ctx.Error(http.StatusInternalServerError, fmt.Sprintf("DeleteAttachment: %v", err))
return
@@ -122,7 +122,7 @@ func ServeAttachment(ctx *context.Context, uuid string) {
}
}
- if err := attach.IncreaseDownloadCount(); err != nil {
+ if err := attach.IncreaseDownloadCount(ctx); err != nil {
ctx.ServerError("IncreaseDownloadCount", err)
return
}
diff --git a/routers/web/repo/editor.go b/routers/web/repo/editor.go
index b053e3c63f..0a606582e5 100644
--- a/routers/web/repo/editor.go
+++ b/routers/web/repo/editor.go
@@ -812,7 +812,7 @@ func UploadFileToServer(ctx *context.Context) {
return
}
- upload, err := repo_model.NewUpload(name, buf, file)
+ upload, err := repo_model.NewUpload(ctx, name, buf, file)
if err != nil {
ctx.Error(http.StatusInternalServerError, fmt.Sprintf("NewUpload: %v", err))
return
@@ -832,7 +832,7 @@ func RemoveUploadFileFromServer(ctx *context.Context) {
return
}
- if err := repo_model.DeleteUploadByUUID(form.File); err != nil {
+ if err := repo_model.DeleteUploadByUUID(ctx, form.File); err != nil {
ctx.Error(http.StatusInternalServerError, fmt.Sprintf("DeleteUploadByUUID: %v", err))
return
}
diff --git a/routers/web/repo/http.go b/routers/web/repo/http.go
index c8ecb3b1d8..1fd784a40a 100644
--- a/routers/web/repo/http.go
+++ b/routers/web/repo/http.go
@@ -158,7 +158,7 @@ func httpBase(ctx *context.Context) *serviceHandler {
}
if ctx.IsBasicAuth && ctx.Data["IsApiToken"] != true && ctx.Data["IsActionsToken"] != true {
- _, err = auth_model.GetTwoFactorByUID(ctx.Doer.ID)
+ _, err = auth_model.GetTwoFactorByUID(ctx, ctx.Doer.ID)
if err == nil {
// TODO: This response should be changed to "invalid credentials" for security reasons once the expectation behind it (creating an app token to authenticate) is properly documented
ctx.PlainText(http.StatusUnauthorized, "Users with two-factor authentication enabled cannot perform HTTP/HTTPS operations via plain username and password. Please create and use a personal access token on the user settings page")
diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go
index 820c5d7233..94c9382f23 100644
--- a/routers/web/repo/issue.go
+++ b/routers/web/repo/issue.go
@@ -1975,7 +1975,7 @@ func ViewIssue(ctx *context.Context) {
var hiddenCommentTypes *big.Int
if ctx.IsSigned {
- val, err := user_model.GetUserSetting(ctx.Doer.ID, user_model.SettingsKeyHiddenCommentTypes)
+ val, err := user_model.GetUserSetting(ctx, ctx.Doer.ID, user_model.SettingsKeyHiddenCommentTypes)
if err != nil {
ctx.ServerError("GetUserSetting", err)
return
@@ -2205,7 +2205,7 @@ func UpdateIssueContent(ctx *context.Context) {
return
}
- if err := issue_service.ChangeContent(issue, ctx.Doer, ctx.Req.FormValue("content")); err != nil {
+ if err := issue_service.ChangeContent(ctx, issue, ctx.Doer, ctx.Req.FormValue("content")); err != nil {
ctx.ServerError("ChangeContent", err)
return
}
@@ -3451,7 +3451,7 @@ func updateAttachments(ctx *context.Context, item any, files []string) error {
if util.SliceContainsString(files, attachments[i].UUID) {
continue
}
- if err := repo_model.DeleteAttachment(attachments[i], true); err != nil {
+ if err := repo_model.DeleteAttachment(ctx, attachments[i], true); err != nil {
return err
}
}
diff --git a/routers/web/repo/middlewares.go b/routers/web/repo/middlewares.go
index 5efc1a82b3..b50e96be3c 100644
--- a/routers/web/repo/middlewares.go
+++ b/routers/web/repo/middlewares.go
@@ -72,12 +72,12 @@ func SetWhitespaceBehavior(ctx *context.Context) {
whitespaceBehavior = defaultWhitespaceBehavior
}
if ctx.IsSigned {
- userWhitespaceBehavior, err := user_model.GetUserSetting(ctx.Doer.ID, user_model.SettingsKeyDiffWhitespaceBehavior, defaultWhitespaceBehavior)
+ userWhitespaceBehavior, err := user_model.GetUserSetting(ctx, ctx.Doer.ID, user_model.SettingsKeyDiffWhitespaceBehavior, defaultWhitespaceBehavior)
if err == nil {
if whitespaceBehavior == "" {
whitespaceBehavior = userWhitespaceBehavior
} else if whitespaceBehavior != userWhitespaceBehavior {
- _ = user_model.SetUserSetting(ctx.Doer.ID, user_model.SettingsKeyDiffWhitespaceBehavior, whitespaceBehavior)
+ _ = user_model.SetUserSetting(ctx, ctx.Doer.ID, user_model.SettingsKeyDiffWhitespaceBehavior, whitespaceBehavior)
}
} // else: we can ignore the error safely
}
@@ -98,7 +98,7 @@ func SetShowOutdatedComments(ctx *context.Context) {
if showOutdatedCommentsValue != "true" && showOutdatedCommentsValue != "false" {
// invalid or no value for this form string -> use default or stored user setting
if ctx.IsSigned {
- showOutdatedCommentsValue, _ = user_model.GetUserSetting(ctx.Doer.ID, user_model.SettingsKeyShowOutdatedComments, "false")
+ showOutdatedCommentsValue, _ = user_model.GetUserSetting(ctx, ctx.Doer.ID, user_model.SettingsKeyShowOutdatedComments, "false")
} else {
// not logged in user -> use the default value
showOutdatedCommentsValue = "false"
@@ -106,7 +106,7 @@ func SetShowOutdatedComments(ctx *context.Context) {
} else {
// valid value -> update user setting if user is logged in
if ctx.IsSigned {
- _ = user_model.SetUserSetting(ctx.Doer.ID, user_model.SettingsKeyShowOutdatedComments, showOutdatedCommentsValue)
+ _ = user_model.SetUserSetting(ctx, ctx.Doer.ID, user_model.SettingsKeyShowOutdatedComments, showOutdatedCommentsValue)
}
}
diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go
index 7772799557..799c2268de 100644
--- a/routers/web/repo/repo.go
+++ b/routers/web/repo/repo.go
@@ -308,9 +308,9 @@ func Action(ctx *context.Context) {
case "unwatch":
err = repo_model.WatchRepo(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID, false)
case "star":
- err = repo_model.StarRepo(ctx.Doer.ID, ctx.Repo.Repository.ID, true)
+ err = repo_model.StarRepo(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID, true)
case "unstar":
- err = repo_model.StarRepo(ctx.Doer.ID, ctx.Repo.Repository.ID, false)
+ err = repo_model.StarRepo(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID, false)
case "accept_transfer":
err = acceptOrRejectRepoTransfer(ctx, true)
case "reject_transfer":
diff --git a/routers/web/repo/setting/collaboration.go b/routers/web/repo/setting/collaboration.go
index 212b0346bc..1e71d33c08 100644
--- a/routers/web/repo/setting/collaboration.go
+++ b/routers/web/repo/setting/collaboration.go
@@ -173,7 +173,7 @@ func AddTeamPost(ctx *context.Context) {
return
}
- if err = org_service.TeamAddRepository(team, ctx.Repo.Repository); err != nil {
+ if err = org_service.TeamAddRepository(ctx, team, ctx.Repo.Repository); err != nil {
ctx.ServerError("TeamAddRepository", err)
return
}
diff --git a/routers/web/repo/setting/settings_test.go b/routers/web/repo/setting/settings_test.go
index 55f292f143..066d2ef2a9 100644
--- a/routers/web/repo/setting/settings_test.go
+++ b/routers/web/repo/setting/settings_test.go
@@ -8,6 +8,7 @@ import (
"testing"
asymkey_model "code.gitea.io/gitea/models/asymkey"
+ "code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/organization"
"code.gitea.io/gitea/models/perm"
repo_model "code.gitea.io/gitea/models/repo"
@@ -248,7 +249,7 @@ func TestAddTeamPost(t *testing.T) {
AddTeamPost(ctx)
- assert.True(t, repo_service.HasRepository(team, re.ID))
+ assert.True(t, repo_service.HasRepository(db.DefaultContext, team, re.ID))
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
assert.Empty(t, ctx.Flash.ErrorMsg)
}
@@ -288,7 +289,7 @@ func TestAddTeamPost_NotAllowed(t *testing.T) {
AddTeamPost(ctx)
- assert.False(t, repo_service.HasRepository(team, re.ID))
+ assert.False(t, repo_service.HasRepository(db.DefaultContext, team, re.ID))
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
assert.NotEmpty(t, ctx.Flash.ErrorMsg)
}
@@ -329,7 +330,7 @@ func TestAddTeamPost_AddTeamTwice(t *testing.T) {
AddTeamPost(ctx)
AddTeamPost(ctx)
- assert.True(t, repo_service.HasRepository(team, re.ID))
+ assert.True(t, repo_service.HasRepository(db.DefaultContext, team, re.ID))
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
assert.NotEmpty(t, ctx.Flash.ErrorMsg)
}
@@ -402,5 +403,5 @@ func TestDeleteTeam(t *testing.T) {
DeleteTeam(ctx)
- assert.False(t, repo_service.HasRepository(team, re.ID))
+ assert.False(t, repo_service.HasRepository(db.DefaultContext, team, re.ID))
}
diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go
index 540a82e865..26e9cedd3a 100644
--- a/routers/web/repo/view.go
+++ b/routers/web/repo/view.go
@@ -1065,7 +1065,7 @@ func Watchers(ctx *context.Context) {
ctx.Data["PageIsWatchers"] = true
RenderUserCards(ctx, ctx.Repo.Repository.NumWatches, func(opts db.ListOptions) ([]*user_model.User, error) {
- return repo_model.GetRepoWatchers(ctx.Repo.Repository.ID, opts)
+ return repo_model.GetRepoWatchers(ctx, ctx.Repo.Repository.ID, opts)
}, tplWatchers)
}
@@ -1075,7 +1075,7 @@ func Stars(ctx *context.Context) {
ctx.Data["CardsTitle"] = ctx.Tr("repo.stargazers")
ctx.Data["PageIsStargazers"] = true
RenderUserCards(ctx, ctx.Repo.Repository.NumStars, func(opts db.ListOptions) ([]*user_model.User, error) {
- return repo_model.GetStargazers(ctx.Repo.Repository, opts)
+ return repo_model.GetStargazers(ctx, ctx.Repo.Repository, opts)
}, tplWatchers)
}
diff --git a/routers/web/shared/user/header.go b/routers/web/shared/user/header.go
index 6273e11fc5..649537ec63 100644
--- a/routers/web/shared/user/header.go
+++ b/routers/web/shared/user/header.go
@@ -34,7 +34,7 @@ func PrepareContextForProfileBigAvatar(ctx *context.Context) {
ctx.Data["ShowUserEmail"] = setting.UI.ShowUserEmail && ctx.ContextUser.Email != "" && ctx.IsSigned && !ctx.ContextUser.KeepEmailPrivate
// Show OpenID URIs
- openIDs, err := user_model.GetUserOpenIDs(ctx.ContextUser.ID)
+ openIDs, err := user_model.GetUserOpenIDs(ctx, ctx.ContextUser.ID)
if err != nil {
ctx.ServerError("GetUserOpenIDs", err)
return
diff --git a/routers/web/user/setting/applications.go b/routers/web/user/setting/applications.go
index 088aba38b6..ee44d48dce 100644
--- a/routers/web/user/setting/applications.go
+++ b/routers/web/user/setting/applications.go
@@ -53,7 +53,7 @@ func ApplicationsPost(ctx *context.Context) {
Scope: scope,
}
- exist, err := auth_model.AccessTokenByNameExists(t)
+ exist, err := auth_model.AccessTokenByNameExists(ctx, t)
if err != nil {
ctx.ServerError("AccessTokenByNameExists", err)
return
@@ -64,7 +64,7 @@ func ApplicationsPost(ctx *context.Context) {
return
}
- if err := auth_model.NewAccessToken(t); err != nil {
+ if err := auth_model.NewAccessToken(ctx, t); err != nil {
ctx.ServerError("NewAccessToken", err)
return
}
@@ -77,7 +77,7 @@ func ApplicationsPost(ctx *context.Context) {
// DeleteApplication response for delete user access token
func DeleteApplication(ctx *context.Context) {
- if err := auth_model.DeleteAccessTokenByID(ctx.FormInt64("id"), ctx.Doer.ID); err != nil {
+ if err := auth_model.DeleteAccessTokenByID(ctx, ctx.FormInt64("id"), ctx.Doer.ID); err != nil {
ctx.Flash.Error("DeleteAccessTokenByID: " + err.Error())
} else {
ctx.Flash.Success(ctx.Tr("settings.delete_token_success"))
@@ -88,7 +88,7 @@ func DeleteApplication(ctx *context.Context) {
func loadApplicationsData(ctx *context.Context) {
ctx.Data["AccessTokenScopePublicOnly"] = auth_model.AccessTokenScopePublicOnly
- tokens, err := auth_model.ListAccessTokens(auth_model.ListAccessTokensOptions{UserID: ctx.Doer.ID})
+ tokens, err := auth_model.ListAccessTokens(ctx, auth_model.ListAccessTokensOptions{UserID: ctx.Doer.ID})
if err != nil {
ctx.ServerError("ListAccessTokens", err)
return
diff --git a/routers/web/user/setting/packages.go b/routers/web/user/setting/packages.go
index 0d2eb14c20..34d18f999e 100644
--- a/routers/web/user/setting/packages.go
+++ b/routers/web/user/setting/packages.go
@@ -107,7 +107,7 @@ func RegenerateChefKeyPair(ctx *context.Context) {
return
}
- if err := user_model.SetUserSetting(ctx.Doer.ID, chef_module.SettingPublicPem, pub); err != nil {
+ if err := user_model.SetUserSetting(ctx, ctx.Doer.ID, chef_module.SettingPublicPem, pub); err != nil {
ctx.ServerError("SetUserSetting", err)
return
}
diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go
index 13c9f08098..2aa6619a49 100644
--- a/routers/web/user/setting/profile.go
+++ b/routers/web/user/setting/profile.go
@@ -348,7 +348,7 @@ func Appearance(ctx *context.Context) {
ctx.Data["PageIsSettingsAppearance"] = true
var hiddenCommentTypes *big.Int
- val, err := user_model.GetUserSetting(ctx.Doer.ID, user_model.SettingsKeyHiddenCommentTypes)
+ val, err := user_model.GetUserSetting(ctx, ctx.Doer.ID, user_model.SettingsKeyHiddenCommentTypes)
if err != nil {
ctx.ServerError("GetUserSetting", err)
return
@@ -420,7 +420,7 @@ func UpdateUserLang(ctx *context.Context) {
// UpdateUserHiddenComments update a user's shown comment types
func UpdateUserHiddenComments(ctx *context.Context) {
- err := user_model.SetUserSetting(ctx.Doer.ID, user_model.SettingsKeyHiddenCommentTypes, forms.UserHiddenCommentTypesFromRequest(ctx).String())
+ err := user_model.SetUserSetting(ctx, ctx.Doer.ID, user_model.SettingsKeyHiddenCommentTypes, forms.UserHiddenCommentTypesFromRequest(ctx).String())
if err != nil {
ctx.ServerError("SetUserSetting", err)
return
diff --git a/routers/web/user/setting/security/2fa.go b/routers/web/user/setting/security/2fa.go
index 0cecb1aa37..7858b634ce 100644
--- a/routers/web/user/setting/security/2fa.go
+++ b/routers/web/user/setting/security/2fa.go
@@ -28,7 +28,7 @@ func RegenerateScratchTwoFactor(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsSecurity"] = true
- t, err := auth.GetTwoFactorByUID(ctx.Doer.ID)
+ t, err := auth.GetTwoFactorByUID(ctx, ctx.Doer.ID)
if err != nil {
if auth.IsErrTwoFactorNotEnrolled(err) {
ctx.Flash.Error(ctx.Tr("settings.twofa_not_enrolled"))
@@ -44,7 +44,7 @@ func RegenerateScratchTwoFactor(ctx *context.Context) {
return
}
- if err = auth.UpdateTwoFactor(t); err != nil {
+ if err = auth.UpdateTwoFactor(ctx, t); err != nil {
ctx.ServerError("SettingsTwoFactor: Failed to UpdateTwoFactor", err)
return
}
@@ -58,7 +58,7 @@ func DisableTwoFactor(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsSecurity"] = true
- t, err := auth.GetTwoFactorByUID(ctx.Doer.ID)
+ t, err := auth.GetTwoFactorByUID(ctx, ctx.Doer.ID)
if err != nil {
if auth.IsErrTwoFactorNotEnrolled(err) {
ctx.Flash.Error(ctx.Tr("settings.twofa_not_enrolled"))
@@ -68,7 +68,7 @@ func DisableTwoFactor(ctx *context.Context) {
return
}
- if err = auth.DeleteTwoFactorByID(t.ID, ctx.Doer.ID); err != nil {
+ if err = auth.DeleteTwoFactorByID(ctx, t.ID, ctx.Doer.ID); err != nil {
if auth.IsErrTwoFactorNotEnrolled(err) {
// There is a potential DB race here - we must have been disabled by another request in the intervening period
ctx.Flash.Success(ctx.Tr("settings.twofa_disabled"))
@@ -145,7 +145,7 @@ func EnrollTwoFactor(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsSecurity"] = true
- t, err := auth.GetTwoFactorByUID(ctx.Doer.ID)
+ t, err := auth.GetTwoFactorByUID(ctx, ctx.Doer.ID)
if t != nil {
// already enrolled - we should redirect back!
log.Warn("Trying to re-enroll %-v in twofa when already enrolled", ctx.Doer)
@@ -171,7 +171,7 @@ func EnrollTwoFactorPost(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsSecurity"] = true
- t, err := auth.GetTwoFactorByUID(ctx.Doer.ID)
+ t, err := auth.GetTwoFactorByUID(ctx, ctx.Doer.ID)
if t != nil {
// already enrolled
ctx.Flash.Error(ctx.Tr("settings.twofa_is_enrolled"))
@@ -237,7 +237,7 @@ func EnrollTwoFactorPost(ctx *context.Context) {
log.Error("Unable to save changes to the session: %v", err)
}
- if err = auth.NewTwoFactor(t); err != nil {
+ if err = auth.NewTwoFactor(ctx, t); err != nil {
// FIXME: We need to handle a unique constraint fail here it's entirely possible that another request has beaten us.
// If there is a unique constraint fail we should just tolerate the error
ctx.ServerError("SettingsTwoFactor: Failed to save two factor", err)
diff --git a/routers/web/user/setting/security/openid.go b/routers/web/user/setting/security/openid.go
index b5509f570f..9a207e149d 100644
--- a/routers/web/user/setting/security/openid.go
+++ b/routers/web/user/setting/security/openid.go
@@ -44,7 +44,7 @@ func OpenIDPost(ctx *context.Context) {
form.Openid = id
log.Trace("Normalized id: " + id)
- oids, err := user_model.GetUserOpenIDs(ctx.Doer.ID)
+ oids, err := user_model.GetUserOpenIDs(ctx, ctx.Doer.ID)
if err != nil {
ctx.ServerError("GetUserOpenIDs", err)
return
@@ -105,7 +105,7 @@ func settingsOpenIDVerify(ctx *context.Context) {
// DeleteOpenID response for delete user's openid
func DeleteOpenID(ctx *context.Context) {
- if err := user_model.DeleteUserOpenID(&user_model.UserOpenID{ID: ctx.FormInt64("id"), UID: ctx.Doer.ID}); err != nil {
+ if err := user_model.DeleteUserOpenID(ctx, &user_model.UserOpenID{ID: ctx.FormInt64("id"), UID: ctx.Doer.ID}); err != nil {
ctx.ServerError("DeleteUserOpenID", err)
return
}
@@ -117,7 +117,7 @@ func DeleteOpenID(ctx *context.Context) {
// ToggleOpenIDVisibility response for toggle visibility of user's openid
func ToggleOpenIDVisibility(ctx *context.Context) {
- if err := user_model.ToggleUserOpenIDVisibility(ctx.FormInt64("id")); err != nil {
+ if err := user_model.ToggleUserOpenIDVisibility(ctx, ctx.FormInt64("id")); err != nil {
ctx.ServerError("ToggleUserOpenIDVisibility", err)
return
}
diff --git a/routers/web/user/setting/security/security.go b/routers/web/user/setting/security/security.go
index dae9bf950d..1ce59fef09 100644
--- a/routers/web/user/setting/security/security.go
+++ b/routers/web/user/setting/security/security.go
@@ -52,7 +52,7 @@ func DeleteAccountLink(ctx *context.Context) {
}
func loadSecurityData(ctx *context.Context) {
- enrolled, err := auth_model.HasTwoFactorByUID(ctx.Doer.ID)
+ enrolled, err := auth_model.HasTwoFactorByUID(ctx, ctx.Doer.ID)
if err != nil {
ctx.ServerError("SettingsTwoFactor", err)
return
@@ -66,7 +66,7 @@ func loadSecurityData(ctx *context.Context) {
}
ctx.Data["WebAuthnCredentials"] = credentials
- tokens, err := auth_model.ListAccessTokens(auth_model.ListAccessTokensOptions{UserID: ctx.Doer.ID})
+ tokens, err := auth_model.ListAccessTokens(ctx, auth_model.ListAccessTokensOptions{UserID: ctx.Doer.ID})
if err != nil {
ctx.ServerError("ListAccessTokens", err)
return
@@ -113,7 +113,7 @@ func loadSecurityData(ctx *context.Context) {
ctx.Data["OrderedOAuth2Names"] = orderedOAuth2Names
ctx.Data["OAuth2Providers"] = oauth2Providers
- openid, err := user_model.GetUserOpenIDs(ctx.Doer.ID)
+ openid, err := user_model.GetUserOpenIDs(ctx, ctx.Doer.ID)
if err != nil {
ctx.ServerError("GetUserOpenIDs", err)
return