mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-04 08:34:30 +01:00 
			
		
		
		
	enable mirror, usestdlibbars and perfsprint part of: https://github.com/go-gitea/gitea/issues/34083 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
		
			
				
	
	
		
			31 lines
		
	
	
		
			701 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			701 B
		
	
	
	
		
			Go
		
	
	
	
	
	
// Copyright 2021 The Gitea Authors. All rights reserved.
 | 
						|
// SPDX-License-Identifier: MIT
 | 
						|
 | 
						|
package externalaccount
 | 
						|
 | 
						|
import (
 | 
						|
	"context"
 | 
						|
	"errors"
 | 
						|
 | 
						|
	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 errors.New("not in LinkAccount session")
 | 
						|
	}
 | 
						|
 | 
						|
	return LinkAccountToUser(ctx, user, gothUser.(goth.User))
 | 
						|
}
 |