user

package
v0.10.6 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoUserInformation = errors.New("no user information")

Functions

func NewContext

func NewContext(ctx context.Context, usr User) context.Context

NewContext returns a new context.Context that carries the provided user ID.

Types

type Config

type Config struct {
	IdentityProviderDefaultName string
}

type DuplicateRecordError

type DuplicateRecordError struct {
	Email string
}

func (DuplicateRecordError) Error

func (e DuplicateRecordError) Error() string

type InvalidError

type InvalidError struct {
	Email string
}

func (InvalidError) Error

func (e InvalidError) Error() string

type NotFoundError

type NotFoundError struct {
	Email string
}

func (NotFoundError) Error

func (e NotFoundError) Error() string

type Repository

type Repository interface {
	Create(ctx context.Context, u *User) (string, error)
	GetByEmail(ctx context.Context, email string) (User, error)
	InsertByEmail(ctx context.Context, u *User) (string, error)
	GetOrInsertByEmail(ctx context.Context, u *User) (string, error)
}

Repository contains interface of supported methods

type Service

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

Service is a type of service that manages business process

func NewService

func NewService(logger log.Logger, repository Repository, opts ...func(*Service)) *Service

NewService initializes user service

func (*Service) ValidateUser

func (s *Service) ValidateUser(ctx context.Context, email string) (string, error)

ValidateUser checks if user email is already in DB if exist in DB, return user ID, if not exist in DB, create a new one

type User

type User struct {
	ID        string    `json:"id" diff:"-" db:"id"`
	Email     string    `json:"email" diff:"email" db:"email"`
	Provider  string    `json:"provider" diff:"-" db:"provider"`
	CreatedAt time.Time `json:"-" diff:"-" db:"created_at"`
	UpdatedAt time.Time `json:"-" diff:"-" db:"updated_at"`
}

User is a basic entity of a user

func FromContext

func FromContext(ctx context.Context) User

FromContext returns the user ID from the context if present, and empty otherwise.

func (*User) Validate

func (u *User) Validate() error

Validate validates a user is valid or not

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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