選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

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. }