mirror of
https://github.com/go-gitea/gitea
synced 2024-11-01 15:54:25 +00:00
4ba642d07d
This reverts #25165 (5bb8d1924d
), as there
was a chance some important reviews got missed.
so after reverting this patch it will be resubmitted for reviewing again
https://github.com/go-gitea/gitea/pull/25165#issuecomment-1960670242
temporary Open #5512 again
31 lines
698 B
Go
31 lines
698 B
Go
// Copyright 2021 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package externalaccount
|
|
|
|
import (
|
|
"context"
|
|
"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(ctx context.Context, store Store, user *user_model.User) error {
|
|
gothUser := store.Get("linkAccountGothUser")
|
|
if gothUser == nil {
|
|
return fmt.Errorf("not in LinkAccount session")
|
|
}
|
|
|
|
return LinkAccountToUser(ctx, user, gothUser.(goth.User))
|
|
}
|