2024-02-07 15:12:23 +00:00
|
|
|
// Copyright 2024 The Forgejo Authors. All rights reserved.
|
2024-02-07 15:42:40 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
package user
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"code.gitea.io/gitea/models/db"
|
|
|
|
"code.gitea.io/gitea/modules/validation"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
db.RegisterModel(new(FederatedUser))
|
|
|
|
}
|
|
|
|
|
2024-02-07 16:11:43 +00:00
|
|
|
func CreateFederationUser(ctx context.Context, user *FederatedUser) error {
|
2024-02-07 15:42:40 +00:00
|
|
|
if res, err := validation.IsValid(user); !res {
|
|
|
|
return fmt.Errorf("FederatedUser is not valid: %v", err)
|
|
|
|
}
|
|
|
|
_, err := db.GetEngine(ctx).Insert(user)
|
|
|
|
return err
|
|
|
|
}
|