entity

package
v14.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: BSD-3-Clause, BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ASC is the ascending order.
	ASC = "ASC"
	// DESC is the descending order.
	DESC = "DESC"
)

Variables

View Source
var ErrAlreadyExists = fmt.Errorf("already exists")

ErrAlreadyExists is a custom error for already existing entities.

View Source
var ErrInvalidArgument = fmt.Errorf("invalid argument")

ErrInvalidArgument is a custom error for invalid arguments.

View Source
var ErrInvalidSortOption = errors.New("invalid sort option")

ErrInvalidSortOption is returned when the sort option is invalid.

View Source
var ErrNotFound = pg.ErrNoRows

ErrNotFound is a type alias of pg.ErrNoRows.

Functions

func FlatTransformer

func FlatTransformer[T any]() auth.Transformer[T]

FlatTransformer returns a transformer for the given type T. It flattens the entity.User to the custom type T. It's used when the custom type T is not the entity.User itself. It returns nil if "T" is already an entity.User. See `sdk.NewAuth` for more.

func GetIDAndUsernameFromFlatUser

func GetIDAndUsernameFromFlatUser(fu FlatUser) (string, string, bool, error)

func GetIDFromFlatUser

func GetIDFromFlatUser(fu FlatUser) (string, bool, error)

GetIDFromFlatUser extracts the user ID from a FlatUser.

func GetPasswordFromFlatUser

func GetPasswordFromFlatUser(fu FlatUser) (string, bool, error)

GetPasswordFromFlatUser extracts the user password from a FlatUser.

func GetUsernameFromFlatUser

func GetUsernameFromFlatUser(fu FlatUser) (string, bool, error)

GetUsernameFromFlatUser extracts the username from a FlatUser.

Types

type Attrs

type Attrs = json.RawMessage // map[string]any

Attrs an alias of the JSONB(json.RawMessage) type, it can be used to store any custom data.

type AttrsBuilder

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

func NewAttrsBuilder

func NewAttrsBuilder() *AttrsBuilder

NewAttrsBuilder creates a new AttrsBuilder.

func (*AttrsBuilder) Set

func (b *AttrsBuilder) Set(key string, value any) *AttrsBuilder

type Billing

type Billing struct {
	MemoryUsedPretty  string  `pg:"type=varchar" json:"memory_used_pretty"`
	NetworkUsedPretty string  `pg:"type=varchar" json:"network_used_pretty"`
	CPUTimePretty     string  `pg:"type=varchar" json:"cpu_time_pretty"`
	TotalCost         float64 `pg:"type=numeric" json:"total_cost"`
}

type ClientRepository

type ClientRepository struct {
	*pg.Repository[oauth2.Client]
}

func NewClientRepository

func NewClientRepository(db *pg.DB) *ClientRepository

NewClientRepository creates a new ClientRepository instance. The most things are handled by the oauth2's postgres client store.

func (*ClientRepository) InTransaction

func (r *ClientRepository) InTransaction(ctx context.Context, fn func(*ClientRepository) error) error

InTransaction executes a function within a database transaction.

func (*ClientRepository) IncrementClientVersion

func (r *ClientRepository) IncrementClientVersion(ctx context.Context, clientID string) (bool, error)

func (*ClientRepository) RestoreTokenMaxAge

func (r *ClientRepository) RestoreTokenMaxAge(ctx context.Context, clientID string) (bool, error)

func (*ClientRepository) UpdateTokenMaxAge

func (r *ClientRepository) UpdateTokenMaxAge(ctx context.Context, clientID string, accessMaxAge, refreshMaxAge int) (bool, error)

type ClientWebhook

type ClientWebhook struct {
	// ID is the primary key of the webhook.
	ID string `pg:"type=uuid,primary" json:"id,omitempty"`
	// CreatedAt is the timestamp when the webhook was created.
	CreatedAt types.ISO8601 `pg:"type=timestamp,default=clock_timestamp()" json:"created_at,omitempty"`
	// UpdatedAt is the timestamp when the webhook was last updated.
	// The updated_at is updated on each row update (see the trigger_set_timestamp sql function).
	UpdatedAt types.ISO8601 `pg:"type=timestamp,default=clock_timestamp()" json:"updated_at,omitempty"`
	// ClientID refers to the client that contains the webhook.
	ClientID string `pg:"type=uuid,ref=oauth2_clients(id cascade),index" json:"client_id"`
	// ActionType is the action type of webhook.
	ActionType WebhookActionType `pg:"type=smallint" json:"action_type"`
	// URL is the webhook URL. This URL is called (with any custom data depends to the ActionType) when the action is triggered.
	URL string `pg:"type=varchar(255)" json:"url"`
}

ClientWebhook represents a webhook for a client. The webhook is called when a specific action is triggered. Many webhooks can be registered for a client, even for the same actions.

type ClientWebhookRepository

type ClientWebhookRepository struct {
	*pg.Repository[ClientWebhook]
}

ClientWebhookRepository handles cost oauth2 client's webhook-related database operations.

func NewClientWebhookRepository

func NewClientWebhookRepository(db *pg.DB) *ClientWebhookRepository

NewClientWebhookRepository creates a new ClientWebhookRepository instance.

func (*ClientWebhookRepository) InTransaction

func (r *ClientWebhookRepository) InTransaction(ctx context.Context, fn func(*ClientWebhookRepository) error) error

InTransaction executes a function within a database transaction.

type FetchOptions

type FetchOptions struct {
	IncludePassword bool // If true, includes password and OTP fields.
	IncludeDeleted  bool // If true, includes soft-deleted users.

	Column string // The column to filter by (e.g., "id", "username").
}

func (*FetchOptions) SetColumn

func (opts *FetchOptions) SetColumn(column string) *FetchOptions

SetColumn sets the column to filter by in the FetchOptions.

type FilterTerm

type FilterTerm struct {
	Field    string `json:"field"`    // e.g. "username", "email", "attrs->>'phone'"
	Operator string `json:"operator"` // e.g. "=", "ILIKE", "@>", etc.
	Value    any    `json:"value"`    // e.g. "makis", "%gmail%", JSON...
	Logic    string `json:"logic"`    // e.g. "AND", "OR" (defaults to AND if empty)
}

FilterTerm represents a filter for querying users.

func (*FilterTerm) Validate

func (f *FilterTerm) Validate() error

Validate checks if the FilterTerm contains valid field, operator, and logic.

type FilterTerms

type FilterTerms []*FilterTerm

type FlatUser

type FlatUser = json.RawMessage // it needs to be a shortcut and not a different type.

FlatUser represents a flattened user structure for JSON output. Custom profile images can be stored in the `photo_url` or `avatar_url` fields. photo_url (snake_case) photoUrl (camelCase) avatar_url (alternative naming) avatarUrl (alternative camelCase)

func FlatUserArrayToSlice

func FlatUserArrayToSlice(raw FlatUser) ([]FlatUser, error)

FlatUserArrayToSlice converts a JSON raw message representing an array into a slice of json.RawMessage.

type Metric

type Metric struct {
	*httpcost.Metric

	ClientID   string `pg:"type=uuid,ref=oauth2_clients(id cascade),index" json:"client_id"`
	Path       string `pg:"type=varchar(255)" json:"path"`
	StatusCode int    `pg:"type=smallint" json:"status_code"`
}

Metric is the cost metric for a request.

type MetricRepository

type MetricRepository struct {
	*pg.Repository[Metric]

	BillingRepository *pg.Repository[Billing]
}

MetricRepository handles cost metric-related database operations.

func NewMetricRepository

func NewMetricRepository(db *pg.DB) *MetricRepository

NewMetricRepository creates a new MetricRepository instance.

func (*MetricRepository) CreateMetric

func (r *MetricRepository) CreateMetric(ctx context.Context, metric Metric) error

CreateMetric stores a new Metric to the database.

func (*MetricRepository) GetBilling

func (r *MetricRepository) GetBilling(ctx context.Context) (Billing, error)

func (*MetricRepository) InTransaction

func (r *MetricRepository) InTransaction(ctx context.Context, fn func(*MetricRepository) error) error

InTransaction executes a function within a database transaction.

type Origin

type Origin struct {
	// CreatedAt is the timestamp when the user was created.
	CreatedAt types.ISO8601 `pg:"type=timestamp,default=clock_timestamp()" json:"created_at,omitempty"`
	// The allowed origin URL pattern.
	// Examples:
	// - "https://example.com"
	// - "https://*.example.com"
	// - "https://*.example.com:8080"
	// - "*" (the default one, allows all origins).
	Pattern string `pg:"type=varchar(255),unique" json:"pattern"`
}

The initial idea was to have a list of allowed origins for CORS requests per oauth2 client, but let's don't coplicate things even more, just have a single one entry of point for all client access, which will also work for the JWKS endpoint (thing that we can't control if we have oauth2 client-based allowed origins).

type OriginRepository

type OriginRepository struct {
	*pg.Repository[Origin]
}

OriginRepository handles allowed CORS origin pattern database operations.

func NewOriginRepository

func NewOriginRepository(db *pg.DB) *OriginRepository

NewOriginRepository creates a new OriginRepository instance.

func (*OriginRepository) DeleteOriginPatterns

func (r *OriginRepository) DeleteOriginPatterns(ctx context.Context, patterns ...string) (bool, error)

func (*OriginRepository) DeleteOriginsExceptWildcardPattern

func (r *OriginRepository) DeleteOriginsExceptWildcardPattern(ctx context.Context) (bool, error)

DeleteOriginsExceptWildcardPattern deletes all origin patterns except the wildcard one.

func (*OriginRepository) InTransaction

func (r *OriginRepository) InTransaction(ctx context.Context, fn func(*OriginRepository) error) error

InTransaction executes a function within a database transaction.

func (*OriginRepository) ListOriginPatterns

func (r *OriginRepository) ListOriginPatterns(ctx context.Context) ([]string, error)

func (*OriginRepository) UpsertOriginPatterns

func (r *OriginRepository) UpsertOriginPatterns(ctx context.Context, patterns ...string) (bool, error)

UpsertOriginPatterns inserts or updates origin patterns in the database. It merges the new patterns with existing ones, ensuring no duplicates. If the patterns are already present, it returns false without making changes. If any patterns are inserted, it returns true. It returns an error if the operation fails. Note that the stored patterns are re-normalized on every call, even when no patterns are given, so a stored set which is not already merged is deleted and re-inserted.

type PageOptions

type PageOptions = context.PageOptions

PageOptions is a simple struct which describes the pagination options. Type alias of context.PageOptions.

type PartialUpdateSpec

type PartialUpdateSpec struct {
	ID       string         `json:"id"`
	Username string         `json:"username"`         // for identification if ID is not provided.
	Set      map[string]any `json:"set,omitempty"`    // paths to set (e.g., {"profile.name": "John", "profile": {"age": 30}}).
	Remove   []string       `json:"remove,omitempty"` // JSON paths to remove (e.g., ["profile.avatar", "settings.notifications"]).
}

PartialUpdateSpec represents a partial update operation for JSONB attrs.

type RecoveryCode

type RecoveryCode struct {
	// Code is the recovery code.
	Code string `json:"code"`
	// Used is the flag that indicates if the recovery code was used.
	Used bool `json:"used"`
}

RecoveryCode is the model that describes a recovery code.

type Registry

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

Registry contains all repositories. It is used to pass the repositories to the services.

func NewRegistry

func NewRegistry(db *pg.DB) *Registry

NewRegistry creates a new postgres Registry.

func (*Registry) ClientWebhooks

func (r *Registry) ClientWebhooks() *ClientWebhookRepository

ClientWebhooks returns the client webhook repository.

func (*Registry) Clients

func (r *Registry) Clients() *ClientRepository

Clients returns the client repository.

func (*Registry) InTransaction

func (r *Registry) InTransaction(ctx context.Context, fn func(*Registry) error) (err error)

InTransaction executes the given function in a transaction.

func (*Registry) IsInTransaction

func (r *Registry) IsInTransaction() bool

IsInTransaction returns true if the current request is in a transaction.

func (*Registry) Metrics

func (r *Registry) Metrics() *MetricRepository

Metrics returns the metric repository.

func (*Registry) Origins

func (r *Registry) Origins() *OriginRepository

Origins returns the origin repository.

func (*Registry) UserGroups

func (r *Registry) UserGroups() *UserGroupRepository

UserGroups returns the user group repository.

func (*Registry) Users

func (r *Registry) Users() *UserRepository

Users returns the user repository.

type UpdateableUser

type UpdateableUser struct {
	ID       string          `json:"id"`
	Username string          `json:"username"`
	Attrs    json.RawMessage `json:"attrs"`
}

UpdateableUser is the model that describes an updateable user.

func (UpdateableUser) ToUser

func (u UpdateableUser) ToUser() User

ToUser converts the updateable user to a user.

type User

type User struct {
	// ID is the primary key of the user.
	ID string `pg:"type=uuid,primary" json:"id,omitempty"`
	// CreatedAt is the timestamp when the user was created.
	CreatedAt types.ISO8601 `pg:"type=timestamp,default=clock_timestamp()" json:"created_at,omitempty"`
	// UpdatedAt is the timestamp when the user was last updated.
	// The updated_at is updated on each row update (see the trigger_set_timestamp sql function).
	UpdatedAt types.ISO8601 `pg:"type=timestamp,default=clock_timestamp()" json:"updated_at,omitempty"`

	// Username is the unique username (or email) of the user.
	Username string `pg:"type=varchar(255),unique" json:"username"` // email or username.
	// Password is the encrypted password of the user.
	Password string `pg:"type=varchar(255)" json:"password,omitempty"` // encrypted password, omit for JSON & JWT responses.
	// OTP is the two-factor authentication key of the user.
	OTP string `pg:"type=varchar(255),default=''" json:"-"` //  otp key url (we can generate a new key based on this, secret lives here too).
	// OTPRecoveryCodes are the recovery codes of the user.
	OTPRecoveryCodes []RecoveryCode `pg:"type=jsonb,default='[]'::jsonb" json:"-"` // 4 recovery codes of 12 chars length that can be used only once (see identity.RecoveryCodesLength and identity.RecoveryCodeLength).
	// Attrs are the custom attributes of the user.
	// The custom attributes are stored as a JSONB column in the database.
	// With a default of {}, every row has an indexed JSONB value (even if empty),
	// so WHERE attrs ? 'foo' or WHERE attrs @> '{"foo":"bar"}' can use the GIN index consistently.
	Attrs Attrs `pg:"type=jsonb,default='{}',index=gin" json:"attrs,omitempty"` // custom attributes.

	DeletedAt types.ISO8601 `pg:"type=timestamp,nullable" json:"-"` // soft delete flag.
}

User is the model that describes a user.

func ToUser

func ToUser(fu FlatUser) (User, error)

ToUser converts the flat user to a user. It is a slow operation and it's only used on some operations.

func (*User) ClearSensitiveFields

func (u *User) ClearSensitiveFields()

ClearSensitiveFields clears the sensitive fields of the user.

func (*User) IsDeleted

func (u *User) IsDeleted() bool

IsDeleted returns true if the user is deleted.

func (User) ToFlatUser

func (u User) ToFlatUser() (FlatUser, error)

ToFlatUser converts the user to a FlatUser.

type UserFilterOptions

type UserFilterOptions struct {
	Sort           string      `json:"sort,omitempty"`        // Optional. Sort expression. The user column to order by, defaults to "created_at".
	SortDescending bool        `json:"sort_descending"`       // Optional. It sorts the result set in descending order by expression.
	Terms          FilterTerms `json:"terms,omitempty"`       // important to be pointer as its validate alters the Logic.
	IncludeDeleted bool        `json:"include_deleted"`       // Optional. Include soft-deleted users in the result set.
	IncludeIDs     []string    `json:"include_ids,omitempty"` // Optional. List of user IDs to include in the result set. If provided, only users with these IDs will be returned.
	// contains filtered or unexported fields
}

UserFilterOptions represents options for filtering and sorting users.

func (*UserFilterOptions) Build

func (f *UserFilterOptions) Build() (string, []any, error)

Build constructs the WHERE clause and arguments for the query based on the filters.

func (*UserFilterOptions) ContainsTermField

func (f *UserFilterOptions) ContainsTermField(fieldName string) bool

ContainsTermField checks if the filter options contain a specific term field.

func (*UserFilterOptions) GetSortOrder

func (f *UserFilterOptions) GetSortOrder() string

GetSortOrder returns the sort order (ASC or DESC) based on the SortDescending flag.

type UserGroup

type UserGroup struct {
	// ID is the primary key of the user group .
	ID string `pg:"type=uuid,primary" json:"id,omitempty"`
	// CreatedAt is the timestamp when the user group was created.
	CreatedAt types.ISO8601 `pg:"type=timestamp,default=clock_timestamp()" json:"created_at,omitempty"`
	// UpdatedAt is the timestamp when the user group was last updated.
	// The updated_at is updated on each row update (see the trigger_set_timestamp sql function).
	UpdatedAt types.ISO8601 `pg:"type=timestamp,default=clock_timestamp()" json:"updated_at,omitempty"`
	// Name is the name of the user group.
	Name string `pg:"type=varchar(255),unique" json:"name,omitempty"`
	// Filter is a JSONB field that contains filter options for the user group.
	Filter UserFilterOptions `pg:"type=jsonb,default='{}'" json:"filter"`
}

type UserGroupFilterOptions

type UserGroupFilterOptions struct {
	Sort           string `json:"sort,omitempty"`  // Optional. Sort expression. The columns that dietitians wish to order by.
	SortDescending bool   `json:"sort_descending"` // Optional. It sorts the result set in descending order by expression.
	Name           string `json:"name,omitempty"`  // Optional. Filter by user group name.
}

UserGroupFilterOptions defines the filter options for querying user groups.

func (*UserGroupFilterOptions) GetSortOrder

func (f *UserGroupFilterOptions) GetSortOrder() string

GetSortOrder returns the sort order (ASC or DESC) based on the SortDescending flag.

type UserGroupRepository

type UserGroupRepository struct {
	*pg.Repository[UserGroup]
}

UserGroupRepository handles user group-related database operations.

func NewUserGroupRepository

func NewUserGroupRepository(db *pg.DB) *UserGroupRepository

NewUserGroupRepository creates a new UserGroupRepository instance.

func (*UserGroupRepository) CountUserGroups

func (r *UserGroupRepository) CountUserGroups(ctx context.Context, f *UserGroupFilterOptions) (total int64, err error)

CountUserGroups returns the total number of user groups matching the filter options.

func (*UserGroupRepository) DeleteUserGroupByID

func (r *UserGroupRepository) DeleteUserGroupByID(ctx context.Context, id string) (bool, error)

DeleteUserGroupByID deletes a user group by its ID.

func (*UserGroupRepository) DeleteUserGroupByName

func (r *UserGroupRepository) DeleteUserGroupByName(ctx context.Context, name string) (bool, error)

DeleteUserGroupByName deletes a user group by its name.

func (*UserGroupRepository) GetUserGroupByID

func (r *UserGroupRepository) GetUserGroupByID(ctx context.Context, id string) (UserGroup, error)

GetUserGroupByID retrieves a user group by its ID.

func (*UserGroupRepository) InTransaction

func (r *UserGroupRepository) InTransaction(ctx context.Context, fn func(*UserGroupRepository) error) error

InTransaction executes a function within a database transaction.

func (*UserGroupRepository) ListUserGroups

ListUserGroups queries the database for user groups based on pagination and filter options.

func (*UserGroupRepository) ListUserGroupsPaginated

func (r *UserGroupRepository) ListUserGroupsPaginated(ctx context.Context, l PageOptions, f *UserGroupFilterOptions) ([]UserGroup, int64, error)

ListUserGroupsPaginated retrieves a paginated list of user groups along with the total count.

func (*UserGroupRepository) UpsertUserGroup

func (r *UserGroupRepository) UpsertUserGroup(ctx context.Context, group UserGroup) (id string, created bool, err error)

type UserRepository

type UserRepository struct {
	*pg.Repository[User]
}

UserRepository handles user-related database operations.

func NewUserRepository

func NewUserRepository(db *pg.DB) *UserRepository

NewUserRepository creates a new UserRepository instance.

func (*UserRepository) BulkDeleteUsers

func (r *UserRepository) BulkDeleteUsers(ctx context.Context, ids []string, soft bool) (int64, error)

func (*UserRepository) BulkInsertUsers

func (r *UserRepository) BulkInsertUsers(ctx context.Context, sharedKeyHex string, users []User) (int64, error)

BulkInsertUsers inserts multiple users in batches with automatic password generation. It inserts multiple users in batches with AES decryption support. If a user's password is empty, generates a strong random password and hashes it. Users are inserted in batches of 500 within separate transactions for optimal performance. If sharedKeyHex is provided, attempts to decrypt AES-encrypted passwords before hashing. Returns the total number of users successfully inserted and any error encountered.

func (*UserRepository) CountTotalUsers

func (r *UserRepository) CountTotalUsers(ctx context.Context) (active, inactive int64, err error)

CountTotalUsers returns the total number of active and inactive users.

func (*UserRepository) CountUsers

func (r *UserRepository) CountUsers(ctx context.Context, f *UserFilterOptions) (total int64, err error)

CountUsers returns the total number of users matching the filter options.

func (*UserRepository) DeleteUserByID

func (r *UserRepository) DeleteUserByID(ctx context.Context, id string, soft bool) (bool, error)

func (*UserRepository) DeleteUserByUsername

func (r *UserRepository) DeleteUserByUsername(ctx context.Context, username string, soft bool) (bool, error)

DeleteUserByUsername deletes a user by username.

func (*UserRepository) GetUser

func (r *UserRepository) GetUser(ctx context.Context, opts FetchOptions, argValue any) (entry User, err error)

func (*UserRepository) GetUserByID

func (r *UserRepository) GetUserByID(ctx context.Context, id string) (entry User, err error)

GetUserByID retrieves an active user by id.

func (*UserRepository) GetUserByUsername

func (r *UserRepository) GetUserByUsername(ctx context.Context, username string) (entry User, err error)

GetUserByUsername retrieves an active user by username.

func (*UserRepository) GetUserByUsernameIncludingDeleted

func (r *UserRepository) GetUserByUsernameIncludingDeleted(ctx context.Context, username string) (entry User, err error)

GetUserByUsernameIncludingDeleted retrieves a user by username, including soft-deleted users.

func (*UserRepository) GetUserFlattened

func (r *UserRepository) GetUserFlattened(ctx context.Context, opts FetchOptions, argValue any) (entry FlatUser, err error)

func (*UserRepository) GetUserIDByUsername

func (r *UserRepository) GetUserIDByUsername(ctx context.Context, username string) (userID string, err error)

GetUserIDByUsername retrieves a user's ID by username (admin access).

func (*UserRepository) InTransaction

func (r *UserRepository) InTransaction(ctx context.Context, fn func(*UserRepository) error) error

InTransaction executes a function within a database transaction.

func (*UserRepository) ListUsers

func (r *UserRepository) ListUsers(ctx context.Context, l PageOptions, f *UserFilterOptions) ([]User, error)

ListUsers queries the database with multiple filters, supporting AND/OR logic.

func (*UserRepository) ListUsersFlattened

func (r *UserRepository) ListUsersFlattened(ctx context.Context, l PageOptions, f *UserFilterOptions) ([]FlatUser, error)

ListUsersFlattened returns a list of users in a flattened JSON format. This is useful for APIs that require a flat structure without nested objects.

func (*UserRepository) ListUsersPaginated

func (r *UserRepository) ListUsersPaginated(ctx context.Context, l PageOptions, f *UserFilterOptions) ([]User, int64, error)

ListUsersPaginated returns a list of users and its filtered total count. Example:

usersPage, totalCount, err := ...ListUsersPaginated(context.Background(), PageOptions{}, &UserFilterOptions{
	Sort:           "created_at",
	SortDescending: true,
	Terms: []*FilterTerm{
		{Field: "username", Operator: "ILIKE", Value: "%Su%"},
		{ /*Logic defaults to AND*/ Field: "attrs->>'key91'", Operator: "=", Value: "148"},
		// {Logic: "OR", Field: "attrs->>'key91'", Operator: "=", Value: "148"},
	},
})

func (*UserRepository) ListUsersPaginatedFlattened

func (r *UserRepository) ListUsersPaginatedFlattened(ctx context.Context, l PageOptions, f *UserFilterOptions) ([]FlatUser, int64, error)

ListUsersPaginatedFlattened returns a list of users in a flattened JSON format and its filtered total count.

func (*UserRepository) RestoreUserAndAttrsByUsername

func (r *UserRepository) RestoreUserAndAttrsByUsername(ctx context.Context, username string, attrs json.RawMessage) (bool, error)

func (*UserRepository) RestoreUserByID

func (r *UserRepository) RestoreUserByID(ctx context.Context, id string) (bool, error)

RestoreUserByID restores a soft-deleted user by its ID.

func (*UserRepository) RestoreUserByUsername

func (r *UserRepository) RestoreUserByUsername(ctx context.Context, username string) (bool, error)

RestoreUserByUsername restores a user by its username.

func (*UserRepository) UpdatePasswordByID

func (r *UserRepository) UpdatePasswordByID(ctx context.Context, id, hashedPassword string) (bool, error)

UpdatePasswordByID updates the password for the given user ID.

func (*UserRepository) UpdatePasswordByUsername

func (r *UserRepository) UpdatePasswordByUsername(ctx context.Context, username, hashedPassword string) (bool, error)

UpdatePasswordByUsername updates the password for the given username.

func (*UserRepository) UpdateUsers

func (r *UserRepository) UpdateUsers(ctx context.Context, users []User, columns ...string) (int64, error)

func (*UserRepository) UpdateUsersPartial

func (r *UserRepository) UpdateUsersPartial(ctx context.Context, updates []PartialUpdateSpec) (int64, error)

UpdateUsersPartial performs partial updates on the core fields and attrs JSONB column This allows updating specific nested fields without replacing the entire attrs object.

type WebhookActionType

type WebhookActionType uint16
const (
	UserPasswordReset WebhookActionType = iota + 1
	UserDeleted                         // 2
)

Jump to

Keyboard shortcuts

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