You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

link.go 661B

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