aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/auth/oauth.go
diff options
context:
space:
mode:
authorJakobDev <jakobdev@gmx.de>2023-09-14 19:09:32 +0200
committerGitHub <noreply@github.com>2023-09-14 17:09:32 +0000
commit76659b1114153603050de810006e04a938e9dcb7 (patch)
treeed180213ca459bca51c44dbcc55fd3f9bc2d0460 /routers/web/auth/oauth.go
parent0de09d3afcb5394cbd97e4a1c5609eb8b2acb6cf (diff)
downloadgitea-76659b1114153603050de810006e04a938e9dcb7.tar.gz
gitea-76659b1114153603050de810006e04a938e9dcb7.zip
Reduce usage of `db.DefaultContext` (#27073)
Part of #27065 This reduces the usage of `db.DefaultContext`. I think I've got enough files for the first PR. When this is merged, I will continue working on this. Considering how many files this PR affect, I hope it won't take to long to merge, so I don't end up in the merge conflict hell. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'routers/web/auth/oauth.go')
-rw-r--r--routers/web/auth/oauth.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/routers/web/auth/oauth.go b/routers/web/auth/oauth.go
index 78dc84472a..178ae84366 100644
--- a/routers/web/auth/oauth.go
+++ b/routers/web/auth/oauth.go
@@ -859,7 +859,7 @@ func SignInOAuth(ctx *context.Context) {
}
// try to do a direct callback flow, so we don't authenticate the user again but use the valid accesstoken to get the user
- user, gothUser, err := oAuth2UserLoginCallback(authSource, ctx.Req, ctx.Resp)
+ user, gothUser, err := oAuth2UserLoginCallback(ctx, authSource, ctx.Req, ctx.Resp)
if err == nil && user != nil {
// we got the user without going through the whole OAuth2 authentication flow again
handleOAuth2SignIn(ctx, authSource, user, gothUser)
@@ -909,7 +909,7 @@ func SignInOAuthCallback(ctx *context.Context) {
return
}
- u, gothUser, err := oAuth2UserLoginCallback(authSource, ctx.Req, ctx.Resp)
+ u, gothUser, err := oAuth2UserLoginCallback(ctx, authSource, ctx.Req, ctx.Resp)
if err != nil {
if user_model.IsErrUserProhibitLogin(err) {
uplerr := err.(user_model.ErrUserProhibitLogin)
@@ -1208,7 +1208,7 @@ func handleOAuth2SignIn(ctx *context.Context, source *auth.Source, u *user_model
// OAuth2UserLoginCallback attempts to handle the callback from the OAuth2 provider and if successful
// login the user
-func oAuth2UserLoginCallback(authSource *auth.Source, request *http.Request, response http.ResponseWriter) (*user_model.User, goth.User, error) {
+func oAuth2UserLoginCallback(ctx *context.Context, authSource *auth.Source, request *http.Request, response http.ResponseWriter) (*user_model.User, goth.User, error) {
oauth2Source := authSource.Cfg.(*oauth2.Source)
// Make sure that the response is not an error response.
@@ -1260,7 +1260,7 @@ func oAuth2UserLoginCallback(authSource *auth.Source, request *http.Request, res
LoginSource: authSource.ID,
}
- hasUser, err := user_model.GetUser(user)
+ hasUser, err := user_model.GetUser(ctx, user)
if err != nil {
return nil, goth.User{}, err
}