mirror of
https://github.com/go-gitea/gitea
synced 2024-11-09 03:21:45 +01:00
e81ccc406b
Change all license headers to comply with REUSE specification. Fix #16132 Co-authored-by: flynnnnnnnnnn <flynnnnnnnnnn@github> Co-authored-by: John Olheiser <john.olheiser@gmail.com>
29 lines
693 B
Go
29 lines
693 B
Go
// Copyright 2021 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package externalaccount
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
user_model "code.gitea.io/gitea/models/user"
|
|
|
|
"github.com/markbates/goth"
|
|
)
|
|
|
|
// Store represents a thing that stores things
|
|
type Store interface {
|
|
Get(interface{}) interface{}
|
|
Set(interface{}, interface{}) error
|
|
Release() error
|
|
}
|
|
|
|
// LinkAccountFromStore links the provided user with a stored external user
|
|
func LinkAccountFromStore(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))
|
|
}
|