aboutsummaryrefslogtreecommitdiffstats
path: root/services/auth/source.go
diff options
context:
space:
mode:
authorJakobDev <jakobdev@gmx.de>2023-10-14 10:37:24 +0200
committerGitHub <noreply@github.com>2023-10-14 08:37:24 +0000
commit76a85a4ce90fead1eb2b743a42b41617b4592889 (patch)
treeef172bbbc48c24e0d95cd5c689426bad16205a69 /services/auth/source.go
parentae419fa49403537725c806a5f3f1e5b274f52eb7 (diff)
downloadgitea-76a85a4ce90fead1eb2b743a42b41617b4592889.tar.gz
gitea-76a85a4ce90fead1eb2b743a42b41617b4592889.zip
Final round of `db.DefaultContext` refactor (#27587)
Last part of #27065
Diffstat (limited to 'services/auth/source.go')
-rw-r--r--services/auth/source.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/services/auth/source.go b/services/auth/source.go
index aae3a78102..69b71a6dea 100644
--- a/services/auth/source.go
+++ b/services/auth/source.go
@@ -4,14 +4,16 @@
package auth
import (
+ "context"
+
"code.gitea.io/gitea/models/auth"
"code.gitea.io/gitea/models/db"
user_model "code.gitea.io/gitea/models/user"
)
// DeleteSource deletes a AuthSource record in DB.
-func DeleteSource(source *auth.Source) error {
- count, err := db.GetEngine(db.DefaultContext).Count(&user_model.User{LoginSource: source.ID})
+func DeleteSource(ctx context.Context, source *auth.Source) error {
+ count, err := db.GetEngine(ctx).Count(&user_model.User{LoginSource: source.ID})
if err != nil {
return err
} else if count > 0 {
@@ -20,7 +22,7 @@ func DeleteSource(source *auth.Source) error {
}
}
- count, err = db.GetEngine(db.DefaultContext).Count(&user_model.ExternalLoginUser{LoginSourceID: source.ID})
+ count, err = db.GetEngine(ctx).Count(&user_model.ExternalLoginUser{LoginSourceID: source.ID})
if err != nil {
return err
} else if count > 0 {
@@ -35,6 +37,6 @@ func DeleteSource(source *auth.Source) error {
}
}
- _, err = db.GetEngine(db.DefaultContext).ID(source.ID).Delete(new(auth.Source))
+ _, err = db.GetEngine(ctx).ID(source.ID).Delete(new(auth.Source))
return err
}