Skip to content

Commit 0032278

Browse files
guillep2kzeripath
authored andcommitted
Allow externalID to be UUID (#8551) (#8624)
Signed-off-by: Wenxuan Zhao <viz@linux.com>
1 parent ccf5298 commit 0032278

File tree

6 files changed

+6
-16
lines changed

6 files changed

+6
-16
lines changed

Diff for: models/external_login_user.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func FindExternalUsersByProvider(opts FindExternalUserOptions) ([]ExternalLoginU
168168
}
169169

170170
// UpdateMigrationsByType updates all migrated repositories' posterid from gitServiceType to replace originalAuthorID to posterID
171-
func UpdateMigrationsByType(tp structs.GitServiceType, externalUserID, userID int64) error {
171+
func UpdateMigrationsByType(tp structs.GitServiceType, externalUserID string, userID int64) error {
172172
if err := UpdateIssuesMigrationsByType(tp, externalUserID, userID); err != nil {
173173
return err
174174
}

Diff for: models/issue.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1950,7 +1950,7 @@ func (issue *Issue) ResolveMentionsByVisibility(ctx DBContext, doer *User, menti
19501950
}
19511951

19521952
// UpdateIssuesMigrationsByType updates all migrated repositories' issues from gitServiceType to replace originalAuthorID to posterID
1953-
func UpdateIssuesMigrationsByType(gitServiceType structs.GitServiceType, originalAuthorID, posterID int64) error {
1953+
func UpdateIssuesMigrationsByType(gitServiceType structs.GitServiceType, originalAuthorID string, posterID int64) error {
19541954
_, err := x.Table("issue").
19551955
Where("repo_id IN (SELECT id FROM repository WHERE original_service_type = ?)", gitServiceType).
19561956
And("original_author_id = ?", originalAuthorID).

Diff for: models/issue_comment.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ func FetchCodeComments(issue *Issue, currentUser *User) (CodeComments, error) {
10251025
}
10261026

10271027
// UpdateCommentsMigrationsByType updates comments' migrations information via given git service type and original id and poster id
1028-
func UpdateCommentsMigrationsByType(tp structs.GitServiceType, originalAuthorID, posterID int64) error {
1028+
func UpdateCommentsMigrationsByType(tp structs.GitServiceType, originalAuthorID string, posterID int64) error {
10291029
_, err := x.Table("comment").
10301030
Where(builder.In("issue_id",
10311031
builder.Select("issue.id").

Diff for: models/release.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ func SyncReleasesWithTags(repo *Repository, gitRepo *git.Repository) error {
369369
}
370370

371371
// UpdateReleasesMigrationsByType updates all migrated repositories' releases from gitServiceType to replace originalAuthorID to posterID
372-
func UpdateReleasesMigrationsByType(gitServiceType structs.GitServiceType, originalAuthorID, posterID int64) error {
372+
func UpdateReleasesMigrationsByType(gitServiceType structs.GitServiceType, originalAuthorID string, posterID int64) error {
373373
_, err := x.Table("release").
374374
Where("repo_id IN (SELECT id FROM repository WHERE original_service_type = ?)", gitServiceType).
375375
And("original_author_id = ?", originalAuthorID).

Diff for: modules/migrations/update.go

+1-7
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
package migrations
66

77
import (
8-
"strconv"
9-
108
"code.gitea.io/gitea/models"
119
"code.gitea.io/gitea/modules/log"
1210
"code.gitea.io/gitea/modules/structs"
@@ -40,11 +38,7 @@ func updateMigrationPosterIDByGitService(tp structs.GitServiceType) error {
4038
}
4139

4240
for _, user := range users {
43-
externalUserID, err := strconv.ParseInt(user.ExternalID, 10, 64)
44-
if err != nil {
45-
log.Warn("Parse externalUser %#v 's userID failed: %v", user, err)
46-
continue
47-
}
41+
externalUserID := user.ExternalID
4842
if err := models.UpdateMigrationsByType(tp, externalUserID, user.UserID); err != nil {
4943
log.Error("UpdateMigrationsByType type %s external user id %v to local user id %v failed: %v", tp.Name(), user.ExternalID, user.UserID, err)
5044
}

Diff for: services/externalaccount/user.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package externalaccount
66

77
import (
8-
"strconv"
98
"strings"
109

1110
"code.gitea.io/gitea/models"
@@ -45,10 +44,7 @@ func LinkAccountToUser(user *models.User, gothUser goth.User) error {
4544
return err
4645
}
4746

48-
externalID, err := strconv.ParseInt(externalLoginUser.ExternalID, 10, 64)
49-
if err != nil {
50-
return err
51-
}
47+
externalID := externalLoginUser.ExternalID
5248

5349
var tp structs.GitServiceType
5450
for _, s := range structs.SupportedFullGitService {

0 commit comments

Comments
 (0)