Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

link.go 698B

123456789101112131415161718192021222324252627282930
  1. // Copyright 2021 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package externalaccount
  4. import (
  5. "context"
  6. "fmt"
  7. user_model "code.gitea.io/gitea/models/user"
  8. "github.com/markbates/goth"
  9. )
  10. // Store represents a thing that stores things
  11. type Store interface {
  12. Get(any) any
  13. Set(any, any) error
  14. Release() error
  15. }
  16. // LinkAccountFromStore links the provided user with a stored external user
  17. func LinkAccountFromStore(ctx context.Context, store Store, user *user_model.User) error {
  18. gothUser := store.Get("linkAccountGothUser")
  19. if gothUser == nil {
  20. return fmt.Errorf("not in LinkAccount session")
  21. }
  22. return LinkAccountToUser(ctx, user, gothUser.(goth.User))
  23. }