aboutsummaryrefslogtreecommitdiffstats
path: root/models/user.go
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2021-11-10 04:21:01 +0100
committerGitHub <noreply@github.com>2021-11-09 22:21:01 -0500
commitedbaa5d3f05b5ca397524587ba9db15edd61bc29 (patch)
treec0359b111705c4873b41c451ccd7076f6ee55c7d /models/user.go
parent465fb4169ecbbef5c460c60f1cdf9b5910610d65 (diff)
downloadgitea-edbaa5d3f05b5ca397524587ba9db15edd61bc29.tar.gz
gitea-edbaa5d3f05b5ca397524587ba9db15edd61bc29.zip
Added GetUserByIDCtx. (#17602)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'models/user.go')
-rw-r--r--models/user.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/models/user.go b/models/user.go
index bf4444802f..d27c581bab 100644
--- a/models/user.go
+++ b/models/user.go
@@ -1392,7 +1392,12 @@ func getUserByID(e db.Engine, id int64) (*User, error) {
// GetUserByID returns the user object by given ID if exists.
func GetUserByID(id int64) (*User, error) {
- return getUserByID(db.GetEngine(db.DefaultContext), id)
+ return GetUserByIDCtx(db.DefaultContext, id)
+}
+
+// GetUserByIDCtx returns the user object by given ID if exists.
+func GetUserByIDCtx(ctx context.Context, id int64) (*User, error) {
+ return getUserByID(db.GetEngine(ctx), id)
}
// GetUserByName returns user by given name.
@@ -1577,7 +1582,7 @@ func GetUserByEmailContext(ctx context.Context, email string) (*User, error) {
return nil, err
}
if has {
- return getUserByID(db.GetEngine(ctx), emailAddress.UID)
+ return GetUserByIDCtx(ctx, emailAddress.UID)
}
// Finally, if email address is the protected email address: