user

package
v0.0.0-...-9b5cd94 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	common.BulkCrudAPI
	Patch(c *gin.Context)
}

func NewApi

func NewApi(
	store Store,
	actionLogger logger.ActionLogger,
	logger zerolog.Logger,
	metricMetaUpdater metrics.MetaUpdater,
) API

type AggregationResult

type AggregationResult struct {
	Data       []User `bson:"data" json:"data"`
	TotalCount int64  `bson:"total_count" json:"total_count"`
}

func (*AggregationResult) GetData

func (r *AggregationResult) GetData() interface{}

func (*AggregationResult) GetTotal

func (r *AggregationResult) GetTotal() int64

type BulkDeleteRequestItem

type BulkDeleteRequestItem struct {
	ID string `json:"_id" binding:"required"`
}

type BulkUpdateRequestItem

type BulkUpdateRequestItem struct {
	ID string `json:"_id" binding:"required"`
	EditRequest
}

type CreateRequest

type CreateRequest struct {
	EditRequest
	Source     string `json:"source" binding:"oneoforempty=ldap cas saml"`
	ExternalID string `json:"external_id"`
}

type EditRequest

type EditRequest struct {
	Password               string   `json:"password"`
	Name                   string   `json:"name" binding:"required,max=255"`
	Firstname              string   `json:"firstname" binding:"max=255"`
	Lastname               string   `json:"lastname" binding:"max=255"`
	Email                  string   `json:"email" binding:"required,email"`
	Roles                  []string `json:"roles" binding:"required,notblank"`
	UILanguage             string   `json:"ui_language" binding:"max=255"`
	UIGroupsNavigationType string   `json:"ui_groups_navigation_type" binding:"max=255"`
	UITheme                string   `json:"ui_theme" binding:"max=255"`
	IsEnabled              *bool    `json:"enable" binding:"required"`
	DefaultView            string   `json:"defaultview"`
}

type ListRequest

type ListRequest struct {
	pagination.FilteredQuery
	SortBy     string `form:"sort_by" binding:"oneoforempty=_id name enable source"`
	Permission string `form:"permission"`
}

type PatchRequest

type PatchRequest struct {
	ID                     string   `json:"-"`
	Password               *string  `json:"password"`
	Name                   *string  `json:"name" binding:"omitempty,max=255"`
	Firstname              *string  `json:"firstname" binding:"omitempty,max=255"`
	Lastname               *string  `json:"lastname" binding:"omitempty,max=255"`
	Email                  *string  `json:"email" binding:"omitempty,email"`
	Roles                  []string `json:"roles" binding:"omitempty,notblank"`
	UILanguage             *string  `json:"ui_language" binding:"omitempty,max=255"`
	UIGroupsNavigationType *string  `json:"ui_groups_navigation_type" binding:"omitempty,max=255"`
	UITheme                *string  `json:"ui_theme" binding:"omitempty,max=255"`
	IsEnabled              *bool    `json:"enable"`
	DefaultView            *string  `json:"defaultview"`
}

type Role

type Role struct {
	ID          string `bson:"_id" json:"_id"`
	Name        string `bson:"name" json:"name"`
	DefaultView *View  `bson:"defaultview" json:"defaultview"`
}

type Store

type Store interface {
	Find(ctx context.Context, r ListRequest) (*AggregationResult, error)
	GetOneBy(ctx context.Context, id string) (*User, error)
	Insert(ctx context.Context, r CreateRequest) (*User, error)
	Update(ctx context.Context, r UpdateRequest) (*User, error)
	Patch(ctx context.Context, r PatchRequest) (*User, error)
	Delete(ctx context.Context, id string) (bool, error)
}

func NewStore

func NewStore(
	dbClient mongo.DbClient,
	passwordEncoder password.Encoder,
	websocketStore websocket.Store,
	authorProvider author.Provider,
) Store

type UpdateRequest

type UpdateRequest struct {
	ID string `json:"-"`
	EditRequest
}

type User

type User struct {
	ID                     string           `bson:"_id" json:"_id"`
	Name                   string           `bson:"name" json:"name"`
	DisplayName            string           `bson:"display_name" json:"display_name"`
	Lastname               string           `bson:"lastname" json:"lastname"`
	Firstname              string           `bson:"firstname" json:"firstname"`
	Email                  string           `bson:"email" json:"email"`
	Roles                  []Role           `bson:"roles" json:"roles"`
	UILanguage             string           `bson:"ui_language" json:"ui_language"`
	UITheme                colortheme.Theme `bson:"ui_theme" json:"ui_theme"`
	UIGroupsNavigationType string           `bson:"ui_groups_navigation_type" json:"ui_groups_navigation_type"`
	Enabled                bool             `bson:"enable" json:"enable"`
	DefaultView            *View            `bson:"defaultview" json:"defaultview"`
	ExternalID             string           `bson:"external_id" json:"external_id"`
	Source                 string           `bson:"source" json:"source"`
	AuthApiKey             string           `bson:"authkey" json:"authkey"`

	ActiveConnects *int64 `bson:"-" json:"active_connects,omitempty"`
}

type Validator

type Validator interface {
	ValidateCreateRequest(ctx context.Context, sl validator.StructLevel)
	ValidateUpdateRequest(ctx context.Context, sl validator.StructLevel)
	ValidatePatchRequest(ctx context.Context, sl validator.StructLevel)
	ValidateBulkUpdateRequestItem(ctx context.Context, sl validator.StructLevel)
}

func NewValidator

func NewValidator(dbClient mongo.DbClient) Validator

type View

type View struct {
	ID    string `bson:"_id" json:"_id"`
	Title string `bson:"title" json:"title"`
}

Jump to

Keyboard shortcuts

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