ubmanage

package
v0.0.25 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const ApiKeyIdLength = 10
View Source
const ApiKeyLength = 40
View Source
const VerificationTokenLength = 10

Variables

This section is empty.

Functions

func MapEvercoreErrorToStatus added in v0.0.14

func MapEvercoreErrorToStatus(err error) ubstatus.StatusCode

func Must

func Must(condition bool, message string)

func NewUserRolesAggregate

func NewUserRolesAggregate() evercore.Aggregate

Note the UserRolesAggregsate is just a receiver for the related events. It does not record state.

Types

type ApiKey added in v0.0.18

type ApiKey struct {
	Id             string `json:"id,omitempty"`
	OrganizationId int64  `json:"organizationId,omitempty"`
	SecretHash     string `json:"secretHash,omitempty"`
	Name           string `json:"name,omitempty"`
	ExpiresAt      int64  `json:"expiresAt,omitempty"`
}

type ApiKeyData added in v0.0.21

type ApiKeyData struct {
	UserId         int64  `json:"userId"`
	Email          string `json:"email,omitempty"`
	OrganizationId int64  `json:"organizationId,omitempty"`
	ExpiresAt      int64  `json:"expiresAt,omitempty"`
}

type GenerateTwoFactorSharedSecretCommand added in v0.0.11

type GenerateTwoFactorSharedSecretCommand struct {
	Id           int64  `json:"id"`
	SharedSecret string `json:"sharedSecret"`
}

type GenerateTwoFactorSharedSecretResponse added in v0.0.11

type GenerateTwoFactorSharedSecretResponse struct {
	SharedSecret string `json:"sharedSecret"`
}

type GroupPermissions added in v0.0.16

type GroupPermissions struct {
	GroupId        int64    `json:"groupId"`
	OrganizationId int64    `json:"organizationId"`
	Permissions    []string `json:"permissions"`
}

type IdValue

type IdValue struct {
	Id int64 `json:"id"`
}

type ManagementImpl

type ManagementImpl struct {
	// contains filtered or unexported fields
}

func (*ManagementImpl) GenerateTwoFactorSharedSecret added in v0.0.11

func (*ManagementImpl) OrganizationAdd

func (m *ManagementImpl) OrganizationAdd(ctx context.Context,
	command OrganizationCreateCommand,
	agent string) (r.Response[IdValue], error)

func (*ManagementImpl) OrganizationGet added in v0.0.16

func (m *ManagementImpl) OrganizationGet(ctx context.Context,
	organizationID int64) (r.Response[OrganizationAggregate], error)

func (*ManagementImpl) OrganizationGetBySystemName

func (m *ManagementImpl) OrganizationGetBySystemName(
	ctx context.Context,
	systemName string) (r.Response[OrganizationAggregate], error)

func (*ManagementImpl) OrganizationList

func (m *ManagementImpl) OrganizationList(ctx context.Context) (r.Response[[]ubdata.Organization], error)

func (*ManagementImpl) OrganizationRolesWithUserCount added in v0.0.16

func (m *ManagementImpl) OrganizationRolesWithUserCount(ctx context.Context, organizationId int64) (r.Response[[]ubdata.ListRolesWithUserCountsRow], error)

func (*ManagementImpl) OrganizationUpdate

func (m *ManagementImpl) OrganizationUpdate(ctx context.Context,
	command OrganizationUpdateCommand,
	agent string) (r.Response[any], error)

func (*ManagementImpl) OrganizationsCount added in v0.0.16

func (m *ManagementImpl) OrganizationsCount(ctx context.Context) (r.Response[int64], error)

func (*ManagementImpl) RoleAdd

func (m *ManagementImpl) RoleAdd(ctx context.Context,
	command RoleCreateCommand,
	agent string) (r.Response[IdValue], error)

func (*ManagementImpl) RoleDelete

func (m *ManagementImpl) RoleDelete(ctx context.Context,
	command RoleDeleteCommand,
	agent string) (r.Response[any], error)

func (*ManagementImpl) RoleGetById

func (m *ManagementImpl) RoleGetById(ctx context.Context,
	roleId int64) (r.Response[RoleAggregate], error)

func (*ManagementImpl) RoleGetBySystemName

func (m *ManagementImpl) RoleGetBySystemName(ctx context.Context,
	systemName string) (r.Response[RoleAggregate], error)

func (*ManagementImpl) RoleList

func (m *ManagementImpl) RoleList(ctx context.Context, OrganizationId int64) (r.Response[[]ubdata.RoleRow], error)

func (*ManagementImpl) RolePermissionAdd

func (m *ManagementImpl) RolePermissionAdd(ctx context.Context,
	command RolePermissionAddCommand,
	agent string) (r.Response[any], error)

func (*ManagementImpl) RolePermissionRemove

func (m *ManagementImpl) RolePermissionRemove(ctx context.Context,
	command RolePermissionRemoveCommand,
	agent string) (r.Response[any], error)

func (*ManagementImpl) RoleUndelete

func (m *ManagementImpl) RoleUndelete(ctx context.Context,
	command RoleUndeleteCommand,
	agent string) (r.Response[any], error)

func (*ManagementImpl) RoleUpdate

func (m *ManagementImpl) RoleUpdate(ctx context.Context,
	command RoleUpdateCommand,
	agent string) (r.Response[any], error)

func (*ManagementImpl) UserAdd

func (*ManagementImpl) UserAddToRole

func (m *ManagementImpl) UserAddToRole(ctx context.Context,
	command UserAddToRoleCommand,
	agent string) (r.Response[any], error)

func (*ManagementImpl) UserAuthenticate

func (m *ManagementImpl) UserAuthenticate(ctx context.Context,
	command UserLoginCommand,
	agent string) (r.Response[*UserAuthenticationResponse], error)

func (*ManagementImpl) UserDeleteApiKey added in v0.0.18

func (m *ManagementImpl) UserDeleteApiKey(ctx context.Context,
	command UserDeleteApiKeyCommand,
	agent string) (r.Response[any], error)

func (*ManagementImpl) UserDisable

func (m *ManagementImpl) UserDisable(ctx context.Context,
	command UserDisableCommand, agent string) (r.Response[any], error)

func (*ManagementImpl) UserEnable

func (m *ManagementImpl) UserEnable(ctx context.Context,
	command UserEnableCommand,
	agent string) (r.Response[any], error)

func (*ManagementImpl) UserGenerateApiKey added in v0.0.18

func (m *ManagementImpl) UserGenerateApiKey(ctx context.Context,
	command UserGenerateApiKeyCommand,
	agent string) (r.Response[string], error)

func (*ManagementImpl) UserGetAllOrganizationRoles added in v0.0.16

func (m *ManagementImpl) UserGetAllOrganizationRoles(ctx context.Context, userId int64) (r.Response[[]ubdata.ListUserOrganizationRolesRow], error)

func (*ManagementImpl) UserGetByApiKey added in v0.0.18

func (m *ManagementImpl) UserGetByApiKey(ctx context.Context,
	apiKey string) (r.Response[UserAggregate], error)

func (*ManagementImpl) UserGetByEmail

func (m *ManagementImpl) UserGetByEmail(ctx context.Context,
	email string) (r.Response[UserAggregate], error)

func (*ManagementImpl) UserGetById

func (m *ManagementImpl) UserGetById(ctx context.Context,
	userId int64) (r.Response[UserAggregate], error)

func (*ManagementImpl) UserGetOrganizationRoles

func (m *ManagementImpl) UserGetOrganizationRoles(ctx context.Context, userId int64, organizationId int64) (r.Response[[]ubdata.RoleRow], error)

func (*ManagementImpl) UserRemoveFromRole

func (m *ManagementImpl) UserRemoveFromRole(ctx context.Context,
	command UserRemoveFromRoleCommand,
	agent string) (r.Response[any], error)

func (*ManagementImpl) UserSetTwoFactorSharedSecret added in v0.0.11

func (m *ManagementImpl) UserSetTwoFactorSharedSecret(ctx context.Context, command UserSetTwoFactorSharedSecretCommand, agent string) (r.Response[any], error)

func (*ManagementImpl) UserUpdate

func (m *ManagementImpl) UserUpdate(ctx context.Context,
	command UserUpdateCommand,
	agent string) (r.Response[any], error)

func (*ManagementImpl) UserVerify

func (m *ManagementImpl) UserVerify(ctx context.Context,
	command UserVerifyCommand,
	agent string) (r.Response[any], error)

func (*ManagementImpl) UserVerifyTwoFactorCode

func (m *ManagementImpl) UserVerifyTwoFactorCode(ctx context.Context,
	command UserVerifyTwoFactorLoginCommand,
	agent string) (r.Response[any], error)

func (*ManagementImpl) UsersCount added in v0.0.16

func (m *ManagementImpl) UsersCount(ctx context.Context) (r.Response[int64], error)

type ManagementService

type ManagementService interface {

	// OrganizationList lists all organizations
	OrganizationList(ctx context.Context) (r.Response[[]ubdata.Organization], error)

	// OrganizationAdd creates a new organization with the given details
	// Returns the ID of the newly created organization or an error
	OrganizationAdd(ctx context.Context,
		command OrganizationCreateCommand,
		agent string) (r.Response[IdValue], error)

	OrganizationGet(ctx context.Context, organizationID int64) (r.Response[OrganizationAggregate], error)

	// OrganizationGetBySystemName retrieves an organization by its system name
	// Returns the organization details or an error if not found
	OrganizationGetBySystemName(
		ctx context.Context,
		systemName string) (r.Response[OrganizationAggregate], error)

	// OrganizationUpdate modifies an existing organization's details
	// Returns success/failure status or an error
	OrganizationUpdate(ctx context.Context,
		command OrganizationUpdateCommand,
		agent string) (r.Response[any], error)

	// RoleAdd creates a new role with the given details
	// Returns the ID of the newly created role or an error
	RoleAdd(ctx context.Context,
		command RoleCreateCommand,
		agent string) (r.Response[IdValue], error)

	// RoleUpdate modifies an existing role's details
	// Returns success/failure status or an error
	RoleUpdate(ctx context.Context,
		command RoleUpdateCommand,
		agent string) (r.Response[any], error)

	// RoleList lists all roles for a given organization
	RoleList(ctx context.Context, OrganizationId int64) (r.Response[[]ubdata.RoleRow], error)

	// RoleGetById retrieves a role by its ID
	// Returns the role details or an error if not found
	RoleGetById(ctx context.Context,
		roleId int64) (r.Response[RoleAggregate], error)

	// RoleGetBySystemName retrieves a role by its system name
	// Returns the role details or an error if not found
	RoleGetBySystemName(ctx context.Context,
		systemName string) (r.Response[RoleAggregate], error)

	// RoleDelete marks a role as deleted (soft delete)
	// Returns success/failure status or an error
	RoleDelete(ctx context.Context,
		command RoleDeleteCommand,
		agent string) (r.Response[any], error)

	// RoleUndelete restores a previously deleted role
	// Returns success/failure status or an error
	RoleUndelete(ctx context.Context,
		command RoleUndeleteCommand,
		agent string) (r.Response[any], error)

	// RolePermissionAdd grants a permission to a role
	// Returns success/failure status or an error
	RolePermissionAdd(ctx context.Context,
		command RolePermissionAddCommand,
		agent string) (r.Response[any], error)

	// RolePermissionRemove revokes a permission from a role
	// Returns success/failure status or an error
	RolePermissionRemove(ctx context.Context,
		command RolePermissionRemoveCommand,
		agent string) (r.Response[any], error)

	// UserAdd creates a new user with the given details
	// Returns the ID of the newly created user or an error
	UserAdd(ctx context.Context,
		command UserCreateCommand,
		agent string) (r.Response[UserCreatedResponse], error)

	// UserGetById retrieves a user by their ID
	// Returns the user details or an error if not found
	UserGetById(ctx context.Context,
		userId int64) (r.Response[UserAggregate], error)

	// UserGetByEmail retrieves a user by email address
	// Returns the user details or an error if not found
	UserGetByEmail(ctx context.Context,
		email string) (r.Response[UserAggregate], error)

	// UserUpdate modifies an existing user's details
	// Returns success/failure status or an error
	UserUpdate(ctx context.Context,
		command UserUpdateCommand,
		agent string) (r.Response[any], error)

	// UserAuthenticate verifies user credentials and authenticates the user
	// Returns authentication status and user details if successful
	UserAuthenticate(ctx context.Context,
		command UserLoginCommand,
		agent string) (r.Response[*UserAuthenticationResponse], error)

	// UserVerifyTwoFactorCode verifies a 2FA code for an authenticated user
	// Returns success/failure status or an error
	UserVerifyTwoFactorCode(ctx context.Context,
		command UserVerifyTwoFactorLoginCommand,
		agent string) (r.Response[any], error)

	// UserGenerateVerificationToken creates a verification token for the user
	// Returns the generated token or an error
	UserGenerateVerificationToken(ctx context.Context,
		command UserGenerateVerificationTokenCommand,
		agent string) (r.Response[UserGenerateVerificationTokenResponse], error)

	// UserVerify verifies a user's account using a verification token
	// Returns success/failure status or an error
	UserVerify(ctx context.Context,
		command UserVerifyCommand,
		agent string) (r.Response[any], error)

	// UserGenerateTwoFactorSharedSecret generates a new 2FA shared secret for the user
	// Returns the secret and setup details or an error
	GenerateTwoFactorSharedSecret(
		ctx context.Context,
		command GenerateTwoFactorSharedSecretCommand) (r.Response[GenerateTwoFactorSharedSecretResponse], error)

	// UserSetTwoFactorSharedSecret sets the 2FA shared secret for the user
	UserSetTwoFactorSharedSecret(ctx context.Context, command UserSetTwoFactorSharedSecretCommand, agent string) (r.Response[any], error)

	// UserDisable deactivates a user account
	// Returns success/failure status or an error
	UserDisable(ctx context.Context,
		command UserDisableCommand,
		agent string) (r.Response[any], error)

	// UserEnable reactivates a previously disabled user account
	// Returns success/failure status or an error
	UserEnable(ctx context.Context,
		command UserEnableCommand,
		agent string) (r.Response[any], error)

	// UserAddToRole assigns a role to a user
	// Returns success/failure status or an error
	UserAddToRole(ctx context.Context,
		command UserAddToRoleCommand,
		agent string) (r.Response[any], error)

	// UserGetOrganizationRoles retrieves all roles a user has in a specific organization
	// Returns the list of roles or an error
	UserGetOrganizationRoles(ctx context.Context, userId int64, organizationId int64) (r.Response[[]ubdata.RoleRow], error)

	UserGetAllOrganizationRoles(ctx context.Context, userId int64) (r.Response[[]ubdata.ListUserOrganizationRolesRow], error)

	// UserRemoveFromRole revokes a role from a user
	// Returns success/failure status or an error
	UserRemoveFromRole(ctx context.Context,
		command UserRemoveFromRoleCommand,
		agent string) (r.Response[any], error)

	// UsersCount returns the total number of users in the system
	UsersCount(ctx context.Context) (r.Response[int64], error)

	UserGenerateApiKey(ctx context.Context,
		command UserGenerateApiKeyCommand,
		agent string) (r.Response[string], error)

	UserGetByApiKey(ctx context.Context,
		apiKey string) (r.Response[UserAggregate], error)

	UserDeleteApiKey(ctx context.Context,
		command UserDeleteApiKeyCommand,
		agent string) (r.Response[any], error)

	// OrganizationsCount returns the total number of organizations in the system
	OrganizationsCount(ctx context.Context) (r.Response[int64], error)

	// ListOrganizationsWithUserCounts lists all organizations along with the count of users in each
	OrganizationRolesWithUserCount(ctx context.Context, organizationId int64) (r.Response[[]ubdata.ListRolesWithUserCountsRow], error)
}

ManagementService defines the interface for user, organization and role management operations

func NewManagement

func NewManagement(
	store *evercore.EventStore,
	dbadapter ubdata.DataAdapter,
	hashingService ubsecurity.HashGenerator,
	encryptionService ubsecurity.EncryptionService,
	twoFactorService ub2fa.TotpService,
) ManagementService

type OrganizationAddedEvent

type OrganizationAddedEvent struct {
	Id         int64  `json:"id"`
	Name       string `json:"name"`
	SystemName string `json:"systemName"`
	Status     string `json:"status"`
}

evercore:state-event

type OrganizationAggregate

type OrganizationAggregate struct {
	evercore.StateAggregate[OrganizationState]
}

evercore:aggregate

type OrganizationCreateCommand

type OrganizationCreateCommand struct {
	Name       string `json:"name"`
	SystemName string `json:"systemName"`
	Status     string `json:"status"`
}

OrganizationCreateCommand is a command to create an organization.

func (OrganizationCreateCommand) Validate

type OrganizationState

type OrganizationState struct {
	Name       string `json:"name"`
	SystemName string `json:"systemName"`
	Status     string `json:"status"`
}

evercore:aggregate

type OrganizationUpdateCommand

type OrganizationUpdateCommand struct {
	Id         int64   `json:"id"`
	Name       *string `json:"name"`
	SystemName *string `json:"systemName"`
	Status     *string `json:"status"`
}

func (OrganizationUpdateCommand) Validate

type OrganizationUpdatedEvent

type OrganizationUpdatedEvent struct {
	Id         int64   `json:"id"`
	Name       *string `json:"name"`
	SystemName *string `json:"systemName"`
	Status     *string `json:"status"`
}

evercore:state-event

type PrefectService added in v0.0.16

type PrefectService interface {
	UserBelongsToRole(ctx context.Context, userId int64, roleId int64) (bool, error)

	UserHasPermission(ctx context.Context, userId int64, orgId int64, permission string) (bool, error)

	GroupInvalidation(ctx context.Context, roleId int64) error

	UserInvalidation(ctx context.Context, userId int64) error

	ApiKeyToUser(ctx context.Context, apiKey string) (ApiKeyData, error)
}

func NewPrefectService added in v0.0.16

func NewPrefectService(
	managementService ManagementService,
	userCacheSize int,
	groupCacheSize int,
) PrefectService

type PrefectServiceImpl added in v0.0.16

type PrefectServiceImpl struct {
	// contains filtered or unexported fields
}

func (*PrefectServiceImpl) ApiKeyToUser added in v0.0.21

func (p *PrefectServiceImpl) ApiKeyToUser(ctx context.Context, apiKey string) (ApiKeyData, error)

func (*PrefectServiceImpl) GroupInvalidation added in v0.0.16

func (p *PrefectServiceImpl) GroupInvalidation(ctx context.Context, groupId int64) error

func (*PrefectServiceImpl) UserBelongsToRole added in v0.0.16

func (p *PrefectServiceImpl) UserBelongsToRole(ctx context.Context, userId int64, groupId int64) (bool, error)

func (*PrefectServiceImpl) UserHasPermission added in v0.0.16

func (p *PrefectServiceImpl) UserHasPermission(ctx context.Context, userId int64, orgId int64, permission string) (bool, error)

func (*PrefectServiceImpl) UserInvalidation added in v0.0.16

func (p *PrefectServiceImpl) UserInvalidation(ctx context.Context, userId int64) error

type RoleAggregate

type RoleAggregate struct {
	evercore.StateAggregate[RoleState]
}

func (*RoleAggregate) ApplyEventState

func (t *RoleAggregate) ApplyEventState(eventState evercore.EventState, eventTime time.Time, reference string) error

type RoleCreateCommand

type RoleCreateCommand struct {
	Name           string `json:"name"`
	SystemName     string `json:"systemName"`
	OrganizationId int64  `json:"organizationId"`
}

RoleCreateCommand is a command to create a role.

func (RoleCreateCommand) Validate

type RoleCreatedEvent

type RoleCreatedEvent struct {
	Id             int64  `json:"id"`
	OrganizationId int64  `json:"organizationId"`
	Name           string `json:"name"`
	SystemName     string `json:"systemName"`
}

evercore:state-event

type RoleDeleteCommand

type RoleDeleteCommand struct {
	Id int64 `json:"id"`
}

type RoleDeletedEvent

type RoleDeletedEvent struct {
}

evercore:event

func (RoleDeletedEvent) GetEventType

func (a RoleDeletedEvent) GetEventType() string

func (RoleDeletedEvent) Serialize

func (a RoleDeletedEvent) Serialize() string

type RolePermissionAddCommand

type RolePermissionAddCommand struct {
	Id         int64  `json:"id"`
	Permission string `json:"permission"`
}

func (RolePermissionAddCommand) Validate

type RolePermissionAddedEvent

type RolePermissionAddedEvent struct {
	Permission string `json:"permission"`
}

evercore:event

func (RolePermissionAddedEvent) GetEventType

func (a RolePermissionAddedEvent) GetEventType() string

func (RolePermissionAddedEvent) Serialize

func (a RolePermissionAddedEvent) Serialize() string

type RolePermissionRemoveCommand

type RolePermissionRemoveCommand struct {
	Id         int64  `json:"id"`
	Permission string `json:"permission"`
}

func (RolePermissionRemoveCommand) Validate

type RolePermissionRemovedEvent

type RolePermissionRemovedEvent struct {
	Permission string `json:"permission"`
}

evercore:event

func (RolePermissionRemovedEvent) GetEventType

func (a RolePermissionRemovedEvent) GetEventType() string

func (RolePermissionRemovedEvent) Serialize

func (a RolePermissionRemovedEvent) Serialize() string

type RoleState

type RoleState struct {
	Name           string `json:"name"`
	OrganizationId int64  `json:"organizationId"`
	SystemName     string `json:"systemName"`
	Deleted        bool   `json:"deleted"`
	Permissions    []string
}

type RoleUndeleteCommand

type RoleUndeleteCommand struct {
	Id int64 `json:"id"`
}

type RoleUndeletedEvent

type RoleUndeletedEvent struct {
}

evercore:event

func (RoleUndeletedEvent) GetEventType

func (a RoleUndeletedEvent) GetEventType() string

func (RoleUndeletedEvent) Serialize

func (a RoleUndeletedEvent) Serialize() string

type RoleUpdateCommand

type RoleUpdateCommand struct {
	Id         int64   `json:"id"`
	Name       *string `json:"name"`
	SystemName *string `json:"systemName"`
}

func (RoleUpdateCommand) Validate

type RoleUpdatedEvent

type RoleUpdatedEvent struct {
	Id         int64   `json:"id"`
	Name       *string `json:"name"`
	SystemName *string `json:"systemName"`
}

evercore:state-event

type UserAddToRoleCommand

type UserAddToRoleCommand struct {
	UserId int64 `json:"userId"`
	RoleId int64 `json:"roleId"`
}

func (UserAddToRoleCommand) Validate

type UserAddedEvent

type UserAddedEvent struct {
	Email        string `json:"email"`
	PasswordHash string `json:"passwordHash"`
	FirstName    string `json:"firstName"`
	LastName     string `json:"lastName"`
	DisplayName  string `json:"displayName"`
	Verified     bool   `json:"verified"`
}

evercore:state-event

type UserAddedToRoleEvent

type UserAddedToRoleEvent struct {
	UserId int64 `json:"userId"`
	RoleId int64 `json:"roleId"`
}

evercore:event

func (UserAddedToRoleEvent) GetEventType

func (a UserAddedToRoleEvent) GetEventType() string

func (UserAddedToRoleEvent) Serialize

func (a UserAddedToRoleEvent) Serialize() string

type UserAggregate

type UserAggregate struct {
	evercore.StateAggregate[UserState]
}

evercore:aggregate

func (*UserAggregate) ApplyEventState

func (t *UserAggregate) ApplyEventState(eventState evercore.EventState, eventTime time.Time, reference string) error

type UserApiKeyAddedEvent added in v0.0.18

type UserApiKeyAddedEvent struct {
	Id             string `json:"id"`
	OrganizationId int64  `json:"organizationId"`
	SecretHash     string `json:"secretHash"`
	Name           string `json:"name"`
	CreatedAt      int64  `json:"createdAt"`
	ExpiresAt      int64  `json:"expiresAt"`
}

evercore:event

func (UserApiKeyAddedEvent) GetEventType added in v0.0.18

func (a UserApiKeyAddedEvent) GetEventType() string

func (UserApiKeyAddedEvent) Serialize added in v0.0.18

func (a UserApiKeyAddedEvent) Serialize() string

type UserApiKeyDeletedEvent added in v0.0.18

type UserApiKeyDeletedEvent struct {
	Id string `json:"apiKeyHash"`
}

evercore:event

func (UserApiKeyDeletedEvent) GetEventType added in v0.0.18

func (a UserApiKeyDeletedEvent) GetEventType() string

func (UserApiKeyDeletedEvent) Serialize added in v0.0.18

func (a UserApiKeyDeletedEvent) Serialize() string

type UserAuthenticationResponse

type UserAuthenticationResponse struct {
	UserId               int64  `json:"user_id"`
	Email                string `json:"email"`
	RequiresTwoFactor    bool   `json:"requires_two_factor"`
	RequiresVerification bool   `json:"requires_verification"`
}

type UserCreateCommand

type UserCreateCommand struct {
	Email                     string `json:"email"`
	Password                  string `json:"password"`
	FirstName                 string `json:"firstName"`
	LastName                  string `json:"lastName"`
	DisplayName               string `json:"displayName"`
	Verified                  bool   `json:"verified"`
	GenerateVerificationToken bool   `json:"verificationRequired"`
}

func (UserCreateCommand) Validate

type UserCreatedResponse added in v0.0.11

type UserCreatedResponse struct {
	Id                int64   `json:"id"`
	VerificationToken *string `json:"-"`
}

type UserData added in v0.0.16

type UserData struct {
	Id    int64   `json:"id"`
	Email string  `json:"email"`
	Roles []int64 `json:"groups"`
}

type UserDeleteApiKeyCommand added in v0.0.18

type UserDeleteApiKeyCommand struct {
	UserId int64  `json:"userId"`
	ApiKey string `json:"apiKey"`
}

type UserDisableCommand

type UserDisableCommand struct {
	Id int64 `json:"id"`
}

type UserDisabledEvent

type UserDisabledEvent struct {
}

evercore:event

func (UserDisabledEvent) GetEventType

func (a UserDisabledEvent) GetEventType() string

func (UserDisabledEvent) Serialize

func (a UserDisabledEvent) Serialize() string

type UserEnableCommand

type UserEnableCommand struct {
	Id int64 `json:"id"`
}

type UserEnabledEvent

type UserEnabledEvent struct {
}

evercore:event

func (UserEnabledEvent) GetEventType

func (a UserEnabledEvent) GetEventType() string

func (UserEnabledEvent) Serialize

func (a UserEnabledEvent) Serialize() string

type UserGenerateApiKeyCommand added in v0.0.18

type UserGenerateApiKeyCommand struct {
	UserId         int64     `json:"userId"`
	Name           string    `json:"name"`
	OrganizationId int64     `json:"organizationId,omitempty"`
	ExpiresAt      time.Time `json:"expiresAt"`
}

func (UserGenerateApiKeyCommand) Validate added in v0.0.21

type UserGenerateVerificationTokenCommand

type UserGenerateVerificationTokenCommand struct {
	Id         int64 `json:"id"`
	Regenerate bool  `json:"regenerate"`
}

func (UserGenerateVerificationTokenCommand) Validate

type UserGenerateVerificationTokenResponse

type UserGenerateVerificationTokenResponse struct {
	Token string `json:"token"`
}

type UserLoginCommand

type UserLoginCommand struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type UserLoginFailedEvent

type UserLoginFailedEvent struct {
	Reason string `json:"reason,omitempty"`
}

evercore:event

func (UserLoginFailedEvent) GetEventType

func (a UserLoginFailedEvent) GetEventType() string

func (UserLoginFailedEvent) Serialize

func (a UserLoginFailedEvent) Serialize() string

type UserLoginPartiallySucceededEvent added in v0.0.16

type UserLoginPartiallySucceededEvent struct {
	RequiresTwoFactor    bool `json:"requiresTwoFactor,omitempty"`
	RequiresVerification bool `json:"requiresVerify,omitempty"`
}

evercore:event

func (UserLoginPartiallySucceededEvent) GetEventType added in v0.0.16

func (a UserLoginPartiallySucceededEvent) GetEventType() string

func (UserLoginPartiallySucceededEvent) Serialize added in v0.0.16

type UserLoginSucceededEvent

type UserLoginSucceededEvent struct {
}

evercore:event

func (UserLoginSucceededEvent) GetEventType

func (a UserLoginSucceededEvent) GetEventType() string

func (UserLoginSucceededEvent) Serialize

func (a UserLoginSucceededEvent) Serialize() string

type UserRemoveFromRoleCommand

type UserRemoveFromRoleCommand struct {
	UserId int64 `json:"userId"`
	RoleId int64 `json:"roleId"`
}

func (UserRemoveFromRoleCommand) Validate

type UserRemovedFromRoleEvent

type UserRemovedFromRoleEvent struct {
	UserId int64 `json:"userId"`
	RoleId int64 `json:"roleId"`
}

evercore:event

func (UserRemovedFromRoleEvent) GetEventType

func (a UserRemovedFromRoleEvent) GetEventType() string

func (UserRemovedFromRoleEvent) Serialize

func (a UserRemovedFromRoleEvent) Serialize() string

type UserRolesAggregate

type UserRolesAggregate struct {
	Id       int64
	Sequence int64
}

evercore:aggregate

func (*UserRolesAggregate) ApplyEventState

func (t *UserRolesAggregate) ApplyEventState(eventState evercore.EventState, eventTime time.Time, reference string) error

func (*UserRolesAggregate) ApplySnapshot

func (t *UserRolesAggregate) ApplySnapshot(snapshot *evercore.Snapshot) error

func (*UserRolesAggregate) GetAggregateType

func (t *UserRolesAggregate) GetAggregateType() string

func (*UserRolesAggregate) GetId

func (t *UserRolesAggregate) GetId() int64

func (*UserRolesAggregate) GetSequence

func (t *UserRolesAggregate) GetSequence() int64

func (*UserRolesAggregate) GetSnapshotFrequency

func (t *UserRolesAggregate) GetSnapshotFrequency() int64

func (*UserRolesAggregate) GetSnapshotState

func (t *UserRolesAggregate) GetSnapshotState() (*string, error)

func (*UserRolesAggregate) SetId

func (t *UserRolesAggregate) SetId(id int64)

func (*UserRolesAggregate) SetSequence

func (t *UserRolesAggregate) SetSequence(seq int64)

type UserSetTwoFactorSharedSecretCommand added in v0.0.11

type UserSetTwoFactorSharedSecretCommand struct {
	Id     int64  `json:"id"`
	Secret string `json:"secret"`
}

type UserState

type UserState struct {
	Email                 string   `json:"email"`
	PasswordHash          string   `json:"passwordHash"`
	FirstName             string   `json:"firstName"`
	LastName              string   `json:"lastName"`
	VerificationToken     *string  `json:"verificationToken,omitempty"`
	Verified              bool     `json:"verified"`
	Disabled              bool     `json:"disabled"`
	DisplayName           string   `json:"displayName"`
	ResetToken            *string  `json:"resetToken,omitempty"`
	LastLogin             int64    `json:"lastLogin,omitempty"`
	LastLoginAttempt      int64    `json:"lastLoginAttempt,omitempty"`
	FailedLoginAttempts   int64    `json:"failedLoginAttempts,omitempty"`
	TwoFactorSharedSecret *string  `json:"twoFactorSharedSecret,omitempty"`
	LoginCount            int64    `json:"loginCount,omitempty"`
	CreatedAt             int64    `json:"createdAt,omitempty"`
	UpdatedAt             int64    `json:"updatedAt,omitempty"`
	ApiKeys               []ApiKey `json:"apiKeys,omitempty"`
}

type UserTwoFactorAuthenticatedEvent

type UserTwoFactorAuthenticatedEvent struct {
}

evercore:event

func (UserTwoFactorAuthenticatedEvent) GetEventType

func (a UserTwoFactorAuthenticatedEvent) GetEventType() string

func (UserTwoFactorAuthenticatedEvent) Serialize

type UserTwoFactorDisabledEvent

type UserTwoFactorDisabledEvent struct {
}

evercore:event

func (UserTwoFactorDisabledEvent) GetEventType

func (a UserTwoFactorDisabledEvent) GetEventType() string

func (UserTwoFactorDisabledEvent) Serialize

func (a UserTwoFactorDisabledEvent) Serialize() string

type UserTwoFactorEnabledEvent

type UserTwoFactorEnabledEvent struct {
	SharedSecret string `json:"sharedSecret"`
}

evercore:event

func (UserTwoFactorEnabledEvent) GetEventType

func (a UserTwoFactorEnabledEvent) GetEventType() string

func (UserTwoFactorEnabledEvent) Serialize

func (a UserTwoFactorEnabledEvent) Serialize() string

type UserUpdateCommand

type UserUpdateCommand struct {
	Id          int64   `json:"id"`
	Email       *string `json:"email"`
	Password    *string `json:"password"`
	FirstName   *string `json:"firstName"`
	LastName    *string `json:"lastName"`
	DisplayName *string `json:"displayName"`
	Verified    *bool   `json:"verified"`
}

func (UserUpdateCommand) Validate

type UserUpdatedEvent

type UserUpdatedEvent struct {
	Id           int64   `json:"id"`
	Email        *string `json:"email"`
	PasswordHash *string `json:"passwordHash"`
	FirstName    *string `json:"firstName"`
	LastName     *string `json:"lastName"`
	DisplayName  *string `json:"displayName"`
	Verified     *bool   `json:"verified"`
}

evercore:state-event

type UserVerificationTokenGeneratedEvent

type UserVerificationTokenGeneratedEvent struct {
	Token       string `json:"token"`
	Regenerated bool   `json:"regenerated"`
}

evercore:event

func (UserVerificationTokenGeneratedEvent) GetEventType

func (UserVerificationTokenGeneratedEvent) Serialize

type UserVerificationTokenVerifiedEvent

type UserVerificationTokenVerifiedEvent struct {
}

evercore:event

func (UserVerificationTokenVerifiedEvent) GetEventType

func (a UserVerificationTokenVerifiedEvent) GetEventType() string

func (UserVerificationTokenVerifiedEvent) Serialize

type UserVerifyCommand

type UserVerifyCommand struct {
	Id           int64  `json:"id"`
	Verification string `json:"verification"`
}

type UserVerifyTwoFactorLoginCommand

type UserVerifyTwoFactorLoginCommand struct {
	UserId int64  `json:"id"`
	Code   string `json:"code"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL