Skip to content

Commit

Permalink
Suppress ExternalLoginUserNotExist error (go-gitea#21504)
Browse files Browse the repository at this point in the history
Fixes go-gitea#21202
Closes go-gitea#21276

An `ExternalLoginUser` is not mandatory if the current user account was
created with/by the external login source.
  • Loading branch information
KN4CK3R committed Oct 24, 2022
1 parent 8043fbc commit 9c91234
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion routers/web/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package auth

import (
"errors"
"fmt"
"net/http"
"strings"
Expand All @@ -23,6 +24,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"
Expand Down Expand Up @@ -613,7 +615,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 !errors.Is(err, util.ErrNotExist) {
log.Error("UpdateExternalUser failed: %v", err)
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion routers/web/auth/oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,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 !errors.Is(err, util.ErrNotExist) {
log.Error("UpdateExternalUser failed: %v", err)
}
}

if err := resetLocale(ctx, u); err != nil {
Expand Down

0 comments on commit 9c91234

Please sign in to comment.