mirror of
https://github.com/harness/drone.git
synced 2025-05-05 14:31:34 +08:00
32 lines
739 B
Go
32 lines
739 B
Go
// Copyright 2022 Harness Inc. All rights reserved.
|
|
// Use of this source code is governed by the Polyform Free Trial License
|
|
// that can be found in the LICENSE.md file for this repository.
|
|
|
|
package system
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/harness/gitness/internal/store"
|
|
)
|
|
|
|
type Controller struct {
|
|
principalStore store.PrincipalStore
|
|
}
|
|
|
|
func NewController(principalStore store.PrincipalStore) *Controller {
|
|
return &Controller{
|
|
principalStore: principalStore,
|
|
}
|
|
}
|
|
|
|
func IsUserRegistrationAllowed(ctx context.Context, principalStore store.PrincipalStore,
|
|
allowSignUpFlag bool) (bool, error) {
|
|
usrCount, err := principalStore.CountUsers(ctx)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
return usrCount == 0 || allowSignUpFlag, nil
|
|
}
|