diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2023-10-15 23:46:06 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-15 17:46:06 +0200 |
commit | cddf245c12223c783c856c87c21cc796ac425439 (patch) | |
tree | 21edf50797c62c3e70dbada95edc20d7ddfd53b8 /services/auth | |
parent | 7480aacdad9470458fa0142beab54b8011bbac25 (diff) | |
download | gitea-cddf245c12223c783c856c87c21cc796ac425439.tar.gz gitea-cddf245c12223c783c856c87c21cc796ac425439.zip |
Replace more db.DefaultContext (#27628)
Target #27065
Diffstat (limited to 'services/auth')
-rw-r--r-- | services/auth/session.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/services/auth/session.go b/services/auth/session.go index 52cfb8ac21..d13813dcbe 100644 --- a/services/auth/session.go +++ b/services/auth/session.go @@ -4,9 +4,9 @@ package auth import ( + "context" "net/http" - "code.gitea.io/gitea/models/db" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/log" ) @@ -29,7 +29,7 @@ func (s *Session) Name() string { // object for that uid. // Returns nil if there is no user uid stored in the session. func (s *Session) Verify(req *http.Request, w http.ResponseWriter, store DataStore, sess SessionStore) (*user_model.User, error) { - user := SessionUser(sess) + user := SessionUser(req.Context(), sess) if user != nil { return user, nil } @@ -37,7 +37,7 @@ func (s *Session) Verify(req *http.Request, w http.ResponseWriter, store DataSto } // SessionUser returns the user object corresponding to the "uid" session variable. -func SessionUser(sess SessionStore) *user_model.User { +func SessionUser(ctx context.Context, sess SessionStore) *user_model.User { if sess == nil { return nil } @@ -55,7 +55,7 @@ func SessionUser(sess SessionStore) *user_model.User { } // Get user object - user, err := user_model.GetUserByID(db.DefaultContext, id) + user, err := user_model.GetUserByID(ctx, id) if err != nil { if !user_model.IsErrUserNotExist(err) { log.Error("GetUserById: %v", err) |