mirror of
https://github.com/SigNoz/signoz.git
synced 2026-06-25 09:30:31 +01:00
Some checks failed
build-staging / prepare (push) Has been cancelled
build-staging / js-build (push) Has been cancelled
build-staging / go-build (push) Has been cancelled
build-staging / staging (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
* feat(user): accept custom roles in user invite * feat(user): use binding package * feat(user): more domain restrictions * feat(user): use suggestions * feat(user): use suggestions * feat(user): use pointer postable role
70 lines
1.3 KiB
Go
70 lines
1.3 KiB
Go
package user
|
|
|
|
import (
|
|
"github.com/SigNoz/signoz/pkg/types"
|
|
"github.com/SigNoz/signoz/pkg/valuer"
|
|
)
|
|
|
|
type createUserOptions struct {
|
|
FactorPassword *types.FactorPassword
|
|
RoleNames []string
|
|
RoleIDs []valuer.UUID
|
|
}
|
|
|
|
type CreateUserOption func(*createUserOptions)
|
|
|
|
func WithFactorPassword(factorPassword *types.FactorPassword) CreateUserOption {
|
|
return func(o *createUserOptions) {
|
|
o.FactorPassword = factorPassword
|
|
}
|
|
}
|
|
|
|
func WithRoleNames(roleNames []string) CreateUserOption {
|
|
return func(o *createUserOptions) {
|
|
o.RoleNames = roleNames
|
|
}
|
|
}
|
|
|
|
func WithRoleIDs(roleIDs []valuer.UUID) CreateUserOption {
|
|
return func(o *createUserOptions) {
|
|
o.RoleIDs = roleIDs
|
|
}
|
|
}
|
|
|
|
func NewCreateUserOptions(opts ...CreateUserOption) *createUserOptions {
|
|
o := &createUserOptions{
|
|
FactorPassword: nil,
|
|
RoleNames: nil,
|
|
}
|
|
|
|
for _, opt := range opts {
|
|
opt(o)
|
|
}
|
|
|
|
return o
|
|
}
|
|
|
|
type authenticateOptions struct {
|
|
OrgID valuer.UUID
|
|
}
|
|
|
|
type AuthenticateOption func(*authenticateOptions)
|
|
|
|
func WithOrgID(orgID valuer.UUID) AuthenticateOption {
|
|
return func(o *authenticateOptions) {
|
|
o.OrgID = orgID
|
|
}
|
|
}
|
|
|
|
func NewAuthenticateOptions(opts ...AuthenticateOption) *authenticateOptions {
|
|
o := &authenticateOptions{
|
|
OrgID: valuer.UUID{},
|
|
}
|
|
|
|
for _, opt := range opts {
|
|
opt(o)
|
|
}
|
|
|
|
return o
|
|
}
|