types

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContextKeyUser         contextKey = "user"
	ContextKeySession      contextKey = "session"
	ContextKeyOrganization contextKey = "organization"
)

Variables

View Source
var (
	// ErrUserNotFound errors.
	ErrUserNotFound       = errs.New("user not found")
	ErrUserAlreadyExists  = errs.New("user already exists")
	ErrEmailAlreadyExists = errs.New("email already exists")
	ErrInvalidCredentials = errs.New("invalid credentials")

	// ErrSessionNotFound errors.
	ErrSessionNotFound = errs.New("session not found")
	ErrSessionExpired  = errs.New("session expired")
	ErrInvalidSession  = errs.New("invalid session")

	// ErrUnauthorized errors.
	ErrUnauthorized     = errs.New("unauthorized")
	ErrForbidden        = errs.New("forbidden")
	ErrEmailNotVerified = errs.New("email not verified")

	// ErrOrganizationNotFound errors.
	ErrOrganizationNotFound  = errs.New("organization not found")
	ErrNotOrganizationMember = errs.New("not an organization member")

	// ErrInvalidInput errors.
	ErrInvalidInput  = errs.New("invalid input")
	ErrInternalError = errs.New("internal error")
)

Common errors.

Functions

func SetAuthContext

func SetAuthContext(ctx context.Context, authCtx *AuthContext) context.Context

SetAuthContext sets auth context in context.

Types

type AuthContext

type AuthContext struct {
	UserID         string
	SessionID      string
	OrganizationID string
	Roles          []string
}

AuthContext contains authentication context.

func GetAuthContext

func GetAuthContext(ctx context.Context) (*AuthContext, bool)

GetAuthContext retrieves auth context from context.

type PaginatedResult

type PaginatedResult struct {
	Data       any
	Total      int
	Page       int
	PageSize   int
	TotalPages int
}

PaginatedResult represents a paginated result.

type PaginationOptions

type PaginationOptions struct {
	Page     int
	PageSize int
	OrderBy  string
	OrderDir string // "asc" or "desc"
}

PaginationOptions options.

func DefaultPagination

func DefaultPagination() PaginationOptions

DefaultPagination returns default pagination options.

type ValidationError

type ValidationError struct {
	Field   string
	Message string
}

ValidationError represents a validation error.

func NewValidationError

func NewValidationError(field, message string) *ValidationError

NewValidationError creates a new validation error.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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