Files
signoz/pkg/modules/user/option.go
Karan Balani b0eec8132b feat: introduce user_role table (#10664)
* feat: introduce user_role table

* fix: golint and register migrations

* fix: user types and order of update user

* feat: add migration to drop role column from users table

* fix: raw queries pointing to role column in users table

* chore: remove storable user struct and minor other changes

* chore: remove refs of calling vars as storable users

* chore: user 0th role instead of highest

* chore: address pr comments

* chore: rename userrolestore to user_role_store

* chore: return userroles with user in getter where possible

* chore: move user module as user setter

* chore: arrange getter and setter methods

* fix: nil pointer for update user in integration test due to half payload being passed

* chore: update openapi specs

* fix: nil errors without making frontend changes

* fix: empty array check everywhere for user roles array and minor other changes

* fix: imports

* fix: rebase changes

* chore: renaming functions

* chore: simplified getorcreateuser user setter method and call sites

* fix: golint

* fix: remove redundant authz migration, remove fk enforcement for drop migration

* fix: add new event for user activation
2026-03-23 13:36:20 +00:00

63 lines
1.1 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
}
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 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
}