mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-24 18:10:52 +00:00
This PR replaces unnecessary calls to formatting functions (`fmt.Printf`, `fmt.Errorf`, ...) by non-formatting equivalents. Resolves #7967 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7994 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: chavacava <chavacava@noreply.codeberg.org> Co-committed-by: chavacava <chavacava@noreply.codeberg.org>
30 lines
693 B
Go
30 lines
693 B
Go
// Copyright 2021 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package externalaccount
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
user_model "forgejo.org/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))
|
|
}
|