Another round of db.DefaultContext
refactor (#27103)
Part of #27065 --------- Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
This commit is contained in:
parent
93bd4351bf
commit
7047df36d4
109 changed files with 353 additions and 306 deletions
|
@ -4,6 +4,7 @@
|
|||
package externalaccount
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
|
@ -19,11 +20,11 @@ type Store interface {
|
|||
}
|
||||
|
||||
// LinkAccountFromStore links the provided user with a stored external user
|
||||
func LinkAccountFromStore(store Store, user *user_model.User) error {
|
||||
func LinkAccountFromStore(ctx context.Context, store Store, user *user_model.User) error {
|
||||
gothUser := store.Get("linkAccountGothUser")
|
||||
if gothUser == nil {
|
||||
return fmt.Errorf("not in LinkAccount session")
|
||||
}
|
||||
|
||||
return LinkAccountToUser(user, gothUser.(goth.User))
|
||||
return LinkAccountToUser(ctx, user, gothUser.(goth.User))
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
package externalaccount
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models/auth"
|
||||
|
@ -42,7 +43,7 @@ func toExternalLoginUser(user *user_model.User, gothUser goth.User) (*user_model
|
|||
}
|
||||
|
||||
// LinkAccountToUser link the gothUser to the user
|
||||
func LinkAccountToUser(user *user_model.User, gothUser goth.User) error {
|
||||
func LinkAccountToUser(ctx context.Context, user *user_model.User, gothUser goth.User) error {
|
||||
externalLoginUser, err := toExternalLoginUser(user, gothUser)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -63,7 +64,7 @@ func LinkAccountToUser(user *user_model.User, gothUser goth.User) error {
|
|||
}
|
||||
|
||||
if tp.Name() != "" {
|
||||
return UpdateMigrationsByType(tp, externalID, user.ID)
|
||||
return UpdateMigrationsByType(ctx, tp, externalID, user.ID)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -80,7 +81,7 @@ func UpdateExternalUser(user *user_model.User, gothUser goth.User) error {
|
|||
}
|
||||
|
||||
// UpdateMigrationsByType updates all migrated repositories' posterid from gitServiceType to replace originalAuthorID to posterID
|
||||
func UpdateMigrationsByType(tp structs.GitServiceType, externalUserID string, userID int64) error {
|
||||
func UpdateMigrationsByType(ctx context.Context, tp structs.GitServiceType, externalUserID string, userID int64) error {
|
||||
if err := issues_model.UpdateIssuesMigrationsByType(tp, externalUserID, userID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -89,7 +90,7 @@ func UpdateMigrationsByType(tp structs.GitServiceType, externalUserID string, us
|
|||
return err
|
||||
}
|
||||
|
||||
if err := repo_model.UpdateReleasesMigrationsByType(tp, externalUserID, userID); err != nil {
|
||||
if err := repo_model.UpdateReleasesMigrationsByType(ctx, tp, externalUserID, userID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue