users

package
v0.0.0-...-51f6740 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeInvalid         = Type(iota)
	TypeSecurityOfficer = Type(iota)
	TypeUser            = Type(iota)
)
View Source
const DefaultSecurityOfficer = "default_security_officer"
View Source
const DefaultUser = "default"

Variables

View Source
var (
	ErrUserNotFound        = errors.New("user not found")
	ErrPasswordIsExpired   = errors.New("password is expired")
	ErrPasswordIsIncorrect = errors.New("password is incorrect")
	ErrPasswordIsNotSet    = errors.New("password is not set")
)

Functions

This section is empty.

Types

type Repository

type Repository interface {
	GetUser(ctx context.Context, username string) (*User, error)
	RecordLoginAttempt(ctx context.Context, userId int64, succeeded bool) error
}

func NewRepository

func NewRepository(logger *logrus.Logger, db *sqlx.DB) Repository

type Service

type Service interface {
	Authenticate(ctx context.Context, userType Type, username string, password string) error
}

func NewService

func NewService(repository Repository) Service

type Type

type Type int

type User

type User struct {
	ID                   int64      `json:"id" db:"id"`
	Type                 Type       `json:"type" db:"type"`
	Username             string     `json:"username" db:"username"`
	HashedPassword       string     `json:"-" db:"hashed_password"`
	LastSucceededLoginAt *time.Time `json:"last_succeeded_login_at" db:"last_succeeded_login_at"`
	LastFailedLoginAt    *time.Time `json:"last_failed_login_at" db:"last_failed_login_at"`
	PasswordExpiredAt    time.Time  `json:"password_expired_at" db:"password_expired_at"`
	CreatedAt            time.Time  `json:"created_at" db:"created_at"`
	UpdatedAt            time.Time  `json:"updated_at" db:"updated_at"`
}

Jump to

Keyboard shortcuts

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