]> source.dussan.org Git - gitea.git/commitdiff
[Fix] Account Linking UpdateMigrationsByType (#31428) (#31434)
authorGiteabot <teabot@gitea.io>
Thu, 20 Jun 2024 13:53:15 +0000 (21:53 +0800)
committerGitHub <noreply@github.com>
Thu, 20 Jun 2024 13:53:15 +0000 (13:53 +0000)
Backport #31428 by Sumit189

Co-authored-by: Sumit <sumit.18.paul@gmail.com>
services/externalaccount/user.go

index e2de41da188e5a9cf15ad0493b76f20df30575c0..3cfd8c81f9fc791c311e9fa4329c70ef60fa3d8f 100644 (file)
@@ -5,6 +5,7 @@ package externalaccount
 
 import (
        "context"
+       "strconv"
        "strings"
 
        "code.gitea.io/gitea/models/auth"
@@ -82,6 +83,11 @@ func UpdateExternalUser(ctx context.Context, user *user_model.User, gothUser got
 
 // UpdateMigrationsByType updates all migrated repositories' posterid from gitServiceType to replace originalAuthorID to posterID
 func UpdateMigrationsByType(ctx context.Context, tp structs.GitServiceType, externalUserID string, userID int64) error {
+       // Skip update if externalUserID is not a valid numeric ID or exceeds int64
+       if _, err := strconv.ParseInt(externalUserID, 10, 64); err != nil {
+               return nil
+       }
+
        if err := issues_model.UpdateIssuesMigrationsByType(ctx, tp, externalUserID, userID); err != nil {
                return err
        }