mirror of
https://github.com/harness/drone.git
synced 2025-05-05 23:42:23 +08:00
28 lines
676 B
Go
28 lines
676 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 user
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/harness/gitness/types"
|
|
)
|
|
|
|
// RegisterCheck checks the DB and env config flag to return boolean
|
|
// which represents if a user sign-up is allowed or not.
|
|
func (c *Controller) RegisterCheck(ctx context.Context, config *types.Config) (*bool, error) {
|
|
usrCount, err := c.principalStore.CountUsers(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
check := false
|
|
if usrCount == 0 || config.AllowSignUp {
|
|
check = true
|
|
}
|
|
|
|
return &check, nil
|
|
}
|