From c36999c1a13903f2d7ec07137726abdbcf20f45d Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Tue, 18 Oct 2022 21:16:36 +0000 Subject: [PATCH 1/3] Suppress error. --- routers/web/auth/auth.go | 4 +++- routers/web/auth/oauth.go | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/routers/web/auth/auth.go b/routers/web/auth/auth.go index 8a4c12d57b573..0a4a3bcd24c52 100644 --- a/routers/web/auth/auth.go +++ b/routers/web/auth/auth.go @@ -619,7 +619,9 @@ func handleUserCreated(ctx *context.Context, u *user_model.User, gothUser *goth. // update external user information if gothUser != nil { if err := externalaccount.UpdateExternalUser(u, *gothUser); err != nil { - log.Error("UpdateExternalUser failed: %v", err) + if !user_model.IsErrExternalLoginUserNotExist(err) { + log.Error("UpdateExternalUser failed: %v", err) + } } } diff --git a/routers/web/auth/oauth.go b/routers/web/auth/oauth.go index c172215b903d1..8788e471e0c82 100644 --- a/routers/web/auth/oauth.go +++ b/routers/web/auth/oauth.go @@ -1068,7 +1068,9 @@ func handleOAuth2SignIn(ctx *context.Context, source *auth.Source, u *user_model // update external user information if err := externalaccount.UpdateExternalUser(u, gothUser); err != nil { - log.Error("UpdateExternalUser failed: %v", err) + if !user_model.IsErrExternalLoginUserNotExist(err) { + log.Error("UpdateExternalUser failed: %v", err) + } } if err := resetLocale(ctx, u); err != nil { From 9089263dca81a1836b68726c4190cf3485a30932 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 19 Oct 2022 01:27:53 +0200 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: delvh --- routers/web/auth/auth.go | 2 +- routers/web/auth/oauth.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/web/auth/auth.go b/routers/web/auth/auth.go index 0a4a3bcd24c52..7c44b6dcafa55 100644 --- a/routers/web/auth/auth.go +++ b/routers/web/auth/auth.go @@ -619,7 +619,7 @@ func handleUserCreated(ctx *context.Context, u *user_model.User, gothUser *goth. // update external user information if gothUser != nil { if err := externalaccount.UpdateExternalUser(u, *gothUser); err != nil { - if !user_model.IsErrExternalLoginUserNotExist(err) { + if !errors.Is(err, util.ErrNotExist) { log.Error("UpdateExternalUser failed: %v", err) } } diff --git a/routers/web/auth/oauth.go b/routers/web/auth/oauth.go index 8788e471e0c82..e0e3c6e59f740 100644 --- a/routers/web/auth/oauth.go +++ b/routers/web/auth/oauth.go @@ -1068,7 +1068,7 @@ func handleOAuth2SignIn(ctx *context.Context, source *auth.Source, u *user_model // update external user information if err := externalaccount.UpdateExternalUser(u, gothUser); err != nil { - if !user_model.IsErrExternalLoginUserNotExist(err) { + if !errors.Is(err, util.ErrNotExist) { log.Error("UpdateExternalUser failed: %v", err) } } From 17ba6dbdff9529f0147ed3a481abb5fcd729f4e4 Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Wed, 19 Oct 2022 06:20:27 +0000 Subject: [PATCH 3/3] Fix imports. --- routers/web/auth/auth.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/routers/web/auth/auth.go b/routers/web/auth/auth.go index 7c44b6dcafa55..b48bdb995177f 100644 --- a/routers/web/auth/auth.go +++ b/routers/web/auth/auth.go @@ -6,6 +6,7 @@ package auth import ( + "errors" "fmt" "net/http" "strings" @@ -24,6 +25,7 @@ import ( "code.gitea.io/gitea/modules/session" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/timeutil" + "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/modules/web" "code.gitea.io/gitea/modules/web/middleware" "code.gitea.io/gitea/routers/utils"