mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-23 19:11:58 +01:00
88f835192d
Result of running `perl -p -i -e 's#interface\{\}#any#g' **/*` and `make fmt`.
Basically the same [as golang did](2580d0e08d
).
29 lines
661 B
Go
29 lines
661 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(any) any
|
|
Set(any, any) 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))
|
|
}
|