0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-11-11 20:41:34 +01:00

Suppress ExternalLoginUserNotExist error (#21504)

Fixes #21202
Closes #21276

An `ExternalLoginUser` is not mandatory if the current user account was
created with/by the external login source.
This commit is contained in:
KN4CK3R 2022-10-19 21:07:21 +02:00 committed by GitHub
parent 6b712465a8
commit 1713beb73b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

@ -6,6 +6,7 @@
package auth package auth
import ( import (
"errors"
"fmt" "fmt"
"net/http" "net/http"
"strings" "strings"
@ -24,6 +25,7 @@ import (
"code.gitea.io/gitea/modules/session" "code.gitea.io/gitea/modules/session"
"code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/modules/web" "code.gitea.io/gitea/modules/web"
"code.gitea.io/gitea/modules/web/middleware" "code.gitea.io/gitea/modules/web/middleware"
"code.gitea.io/gitea/routers/utils" "code.gitea.io/gitea/routers/utils"
@ -619,9 +621,11 @@ func handleUserCreated(ctx *context.Context, u *user_model.User, gothUser *goth.
// update external user information // update external user information
if gothUser != nil { if gothUser != nil {
if err := externalaccount.UpdateExternalUser(u, *gothUser); err != nil { if err := externalaccount.UpdateExternalUser(u, *gothUser); err != nil {
if !errors.Is(err, util.ErrNotExist) {
log.Error("UpdateExternalUser failed: %v", err) log.Error("UpdateExternalUser failed: %v", err)
} }
} }
}
// Send confirmation email // Send confirmation email
if !u.IsActive && u.ID > 1 { if !u.IsActive && u.ID > 1 {

View file

@ -1068,8 +1068,10 @@ func handleOAuth2SignIn(ctx *context.Context, source *auth.Source, u *user_model
// update external user information // update external user information
if err := externalaccount.UpdateExternalUser(u, gothUser); err != nil { if err := externalaccount.UpdateExternalUser(u, gothUser); err != nil {
if !errors.Is(err, util.ErrNotExist) {
log.Error("UpdateExternalUser failed: %v", err) log.Error("UpdateExternalUser failed: %v", err)
} }
}
if err := resetLocale(ctx, u); err != nil { if err := resetLocale(ctx, u); err != nil {
ctx.ServerError("resetLocale", err) ctx.ServerError("resetLocale", err)