users

package
v0.0.0-...-be2ef80 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 1 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter interface {
	GetUsers(context.Context) (Users, error)
	GetUser(ctx context.Context, email string) (*ShowUser, error)
	GetPassword(ctx context.Context, email string) (*UserWithHashedPass, error)
	CreateUser(ctx context.Context, user User) (*ShowUser, error)
	UpdateUser(ctx context.Context, user UserWithHashedPass) (*ShowUser, error)
	DeleteUser(ctx context.Context, email string) (bool, error)
	HashPassword(password string) ([]byte, error)
	ValidatePassword(ctx context.Context, username, password string) (valid bool, err error)
	CreateUserWithHashedPass(ctx context.Context, user UserWithHashedPass) (*ShowUser, error)
}

Adapter is the interface for various adapters

type AlreadyExistsError

type AlreadyExistsError struct{}

AlreadyExistsError is returned when the user's email already exists in the database

func (*AlreadyExistsError) Error

func (e *AlreadyExistsError) Error() string

type NotFoundError

type NotFoundError struct{}

NotFoundError is the error returned when the user wasn't found, to discern this from other errors -- failures to reach the backend services, etc.

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

type ShowUser

type ShowUser struct {
	ID    string `json:"id" binding:"required"`
	Name  string `json:"name" binding:"required"`
	Email string `json:"email" binding:"required"`
}

ShowUser does not have the password field so we don't accidentally expose it

type User

type User struct {
	ID       string `json:"id"`
	Name     string `json:"name" binding:"required"`
	Email    string `json:"email" binding:"required"`
	Password string `json:"password" binding:"required"`
}

User is the type of a struct of User data

type UserWithHashedPass

type UserWithHashedPass struct {
	ShowUser
	HashedPass []byte
}

type Users

type Users map[string]ShowUser

Users is the type of a list of Users

Directories

Path Synopsis
nolint: govet
nolint: govet

Jump to

Keyboard shortcuts

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