summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWenxuan Zhao <viz@linux.com>2019-10-16 19:06:28 -0700
committerLunny Xiao <xiaolunwen@gmail.com>2019-10-17 10:06:28 +0800
commitcf42cb0ae63c733f93b48a868873c8cd5a2b90bb (patch)
tree54abbd469f6655ea124820ca9821e05af39a9105
parentc43feedb96bd0ccf238bea59803ea412108b4000 (diff)
downloadgitea-cf42cb0ae63c733f93b48a868873c8cd5a2b90bb.tar.gz
gitea-cf42cb0ae63c733f93b48a868873c8cd5a2b90bb.zip
Allow externalID to be UUID (#8551)
Signed-off-by: Wenxuan Zhao <viz@linux.com>
-rw-r--r--models/external_login_user.go2
-rw-r--r--models/issue.go2
-rw-r--r--models/issue_comment.go2
-rw-r--r--models/release.go2
-rw-r--r--modules/migrations/update.go8
-rw-r--r--services/externalaccount/user.go6
6 files changed, 6 insertions, 16 deletions
diff --git a/models/external_login_user.go b/models/external_login_user.go
index 59c3732184..f6357b8274 100644
--- a/models/external_login_user.go
+++ b/models/external_login_user.go
@@ -168,7 +168,7 @@ func FindExternalUsersByProvider(opts FindExternalUserOptions) ([]ExternalLoginU
}
// UpdateMigrationsByType updates all migrated repositories' posterid from gitServiceType to replace originalAuthorID to posterID
-func UpdateMigrationsByType(tp structs.GitServiceType, externalUserID, userID int64) error {
+func UpdateMigrationsByType(tp structs.GitServiceType, externalUserID string, userID int64) error {
if err := UpdateIssuesMigrationsByType(tp, externalUserID, userID); err != nil {
return err
}
diff --git a/models/issue.go b/models/issue.go
index 6503a0618f..c55e96168f 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -1936,7 +1936,7 @@ func (issue *Issue) ResolveMentionsByVisibility(ctx DBContext, doer *User, menti
}
// UpdateIssuesMigrationsByType updates all migrated repositories' issues from gitServiceType to replace originalAuthorID to posterID
-func UpdateIssuesMigrationsByType(gitServiceType structs.GitServiceType, originalAuthorID, posterID int64) error {
+func UpdateIssuesMigrationsByType(gitServiceType structs.GitServiceType, originalAuthorID string, posterID int64) error {
_, err := x.Table("issue").
Where("repo_id IN (SELECT id FROM repository WHERE original_service_type = ?)", gitServiceType).
And("original_author_id = ?", originalAuthorID).
diff --git a/models/issue_comment.go b/models/issue_comment.go
index ccf239d600..ffc3c006f5 100644
--- a/models/issue_comment.go
+++ b/models/issue_comment.go
@@ -1046,7 +1046,7 @@ func FetchCodeComments(issue *Issue, currentUser *User) (CodeComments, error) {
}
// UpdateCommentsMigrationsByType updates comments' migrations information via given git service type and original id and poster id
-func UpdateCommentsMigrationsByType(tp structs.GitServiceType, originalAuthorID, posterID int64) error {
+func UpdateCommentsMigrationsByType(tp structs.GitServiceType, originalAuthorID string, posterID int64) error {
_, err := x.Table("comment").
Where(builder.In("issue_id",
builder.Select("issue.id").
diff --git a/models/release.go b/models/release.go
index 03685e0a44..f43d81d822 100644
--- a/models/release.go
+++ b/models/release.go
@@ -369,7 +369,7 @@ func SyncReleasesWithTags(repo *Repository, gitRepo *git.Repository) error {
}
// UpdateReleasesMigrationsByType updates all migrated repositories' releases from gitServiceType to replace originalAuthorID to posterID
-func UpdateReleasesMigrationsByType(gitServiceType structs.GitServiceType, originalAuthorID, posterID int64) error {
+func UpdateReleasesMigrationsByType(gitServiceType structs.GitServiceType, originalAuthorID string, posterID int64) error {
_, err := x.Table("release").
Where("repo_id IN (SELECT id FROM repository WHERE original_service_type = ?)", gitServiceType).
And("original_author_id = ?", originalAuthorID).
diff --git a/modules/migrations/update.go b/modules/migrations/update.go
index df626ddd95..d1465b2baf 100644
--- a/modules/migrations/update.go
+++ b/modules/migrations/update.go
@@ -5,8 +5,6 @@
package migrations
import (
- "strconv"
-
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/structs"
@@ -40,11 +38,7 @@ func updateMigrationPosterIDByGitService(tp structs.GitServiceType) error {
}
for _, user := range users {
- externalUserID, err := strconv.ParseInt(user.ExternalID, 10, 64)
- if err != nil {
- log.Warn("Parse externalUser %#v 's userID failed: %v", user, err)
- continue
- }
+ externalUserID := user.ExternalID
if err := models.UpdateMigrationsByType(tp, externalUserID, user.UserID); err != nil {
log.Error("UpdateMigrationsByType type %s external user id %v to local user id %v failed: %v", tp.Name(), user.ExternalID, user.UserID, err)
}
diff --git a/services/externalaccount/user.go b/services/externalaccount/user.go
index 800546f123..45773fdb12 100644
--- a/services/externalaccount/user.go
+++ b/services/externalaccount/user.go
@@ -5,7 +5,6 @@
package externalaccount
import (
- "strconv"
"strings"
"code.gitea.io/gitea/models"
@@ -45,10 +44,7 @@ func LinkAccountToUser(user *models.User, gothUser goth.User) error {
return err
}
- externalID, err := strconv.ParseInt(externalLoginUser.ExternalID, 10, 64)
- if err != nil {
- return err
- }
+ externalID := externalLoginUser.ExternalID
var tp structs.GitServiceType
for _, s := range structs.SupportedFullGitService {