password

package
v0.0.0-...-9305a47 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateParams

type CreateParams struct {
	UserID       int64  `json:"userId"`
	PasswordHash string `json:"passwordHash"`
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type Password

type Password struct {
	ID             int64        `json:"id"`
	UserID         int64        `json:"userId"`
	PasswordHash   string       `json:"passwordHash"`
	FailedAttempts int64        `json:"failedAttempts"`
	CreatedAt      time.Time    `json:"createdAt"`
	UpdatedAt      time.Time    `json:"updatedAt"`
	DeletedAt      sql.NullTime `json:"deletedAt"`
	BlockedAt      sql.NullTime `json:"blockedAt"`
}

type Querier

type Querier interface {
	//Create
	//
	//  INSERT INTO passwords (user_id, password_hash)
	//  VALUES (?, ?)
	//  RETURNING id, user_id, password_hash, failed_attempts, created_at, updated_at, deleted_at, blocked_at
	Create(ctx context.Context, arg CreateParams) (*Password, error)
	//GetByUserID
	//
	//  SELECT id, user_id, password_hash, failed_attempts, created_at, updated_at, deleted_at, blocked_at
	//  FROM passwords
	//  WHERE user_id = ?
	//    AND deleted_at IS NULL
	GetByUserID(ctx context.Context, userID int64) (*Password, error)
	//IncreaseFailedAttempts
	//
	//  UPDATE passwords
	//  SET failed_attempts = failed_attempts + 1, updated_at = datetime('now')
	//  WHERE id = ?
	//    AND deleted_at IS NULL
	//  RETURNING id, user_id, password_hash, failed_attempts, created_at, updated_at, deleted_at, blocked_at
	IncreaseFailedAttempts(ctx context.Context, id int64) (*Password, error)
	//ResetFailedAttempts
	//
	//  UPDATE passwords
	//  SET failed_attempts = 0, updated_at = datetime('now')
	//  WHERE id = ?
	//    AND deleted_at IS NULL
	//  RETURNING id, user_id, password_hash, failed_attempts, created_at, updated_at, deleted_at, blocked_at
	ResetFailedAttempts(ctx context.Context, id int64) (*Password, error)
	//Update
	//
	//  UPDATE passwords
	//  SET password_hash = ?, updated_at = datetime('now')
	//  WHERE id = ?
	//    AND deleted_at IS NULL
	//  RETURNING id, user_id, password_hash, failed_attempts, created_at, updated_at, deleted_at, blocked_at
	Update(ctx context.Context, arg UpdateParams) (*Password, error)
}

type Queries

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

func New

func New(db DBTX) *Queries

func Prepare

func Prepare(ctx context.Context, db DBTX) (*Queries, error)

func (*Queries) Close

func (q *Queries) Close() error

func (*Queries) Create

func (q *Queries) Create(ctx context.Context, arg CreateParams) (*Password, error)

Create

INSERT INTO passwords (user_id, password_hash)
VALUES (?, ?)
RETURNING id, user_id, password_hash, failed_attempts, created_at, updated_at, deleted_at, blocked_at

func (*Queries) GetByUserID

func (q *Queries) GetByUserID(ctx context.Context, userID int64) (*Password, error)

GetByUserID

SELECT id, user_id, password_hash, failed_attempts, created_at, updated_at, deleted_at, blocked_at
FROM passwords
WHERE user_id = ?
  AND deleted_at IS NULL

func (*Queries) IncreaseFailedAttempts

func (q *Queries) IncreaseFailedAttempts(ctx context.Context, id int64) (*Password, error)

IncreaseFailedAttempts

UPDATE passwords
SET failed_attempts = failed_attempts + 1, updated_at = datetime('now')
WHERE id = ?
  AND deleted_at IS NULL
RETURNING id, user_id, password_hash, failed_attempts, created_at, updated_at, deleted_at, blocked_at

func (*Queries) ResetFailedAttempts

func (q *Queries) ResetFailedAttempts(ctx context.Context, id int64) (*Password, error)

ResetFailedAttempts

UPDATE passwords
SET failed_attempts = 0, updated_at = datetime('now')
WHERE id = ?
  AND deleted_at IS NULL
RETURNING id, user_id, password_hash, failed_attempts, created_at, updated_at, deleted_at, blocked_at

func (*Queries) Update

func (q *Queries) Update(ctx context.Context, arg UpdateParams) (*Password, error)

Update

UPDATE passwords
SET password_hash = ?, updated_at = datetime('now')
WHERE id = ?
  AND deleted_at IS NULL
RETURNING id, user_id, password_hash, failed_attempts, created_at, updated_at, deleted_at, blocked_at

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type UpdateParams

type UpdateParams struct {
	PasswordHash string `json:"passwordHash"`
	ID           int64  `json:"id"`
}

Jump to

Keyboard shortcuts

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