models

package
v0.0.0-...-258e4f8 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScopeAuthentication = "authentication"
)

Variables

View Source
var AnonymousUser = &User{}

Functions

func IsValidAdmin

func IsValidAdmin(db *pgxpool.Pool, token string) (bool, error)

func ValidateEmail

func ValidateEmail(v *core.Validator, email string)

func ValidatePasswordPlaintext

func ValidatePasswordPlaintext(v *core.Validator, password string)

Types

type Token

type Token struct {
	Plaintext string    `json:"token"`
	Hash      []byte    `json:"-"`
	UserID    int64     `json:"-"`
	Expiry    time.Time `json:"expiry"`
	Scope     string    `json:"-"`
}

func NewToken

func NewToken(db *pgxpool.Pool, userID int64, ttl time.Duration, scope string) (*Token, error)

type User

type User struct {
	ID        int64     `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	Name      string    `json:"name"`
	Email     string    `json:"email"`
	Password  password  `json:"-"`
}

func GetByEmail

func GetByEmail(ctx context.Context, db *pgxpool.Pool, email string) (*User, error)

func (*User) IsAnonymous

func (u *User) IsAnonymous() bool

Jump to

Keyboard shortcuts

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