model

package
v0.0.0-...-08046e1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SecretByteLen is the length in byte of the secret.
	SecretByteLen int = 64
	// PasswordByteLen is the length in byte of the secret.
	PasswordByteLen int = 16
)

Variables

This section is empty.

Functions

func NewUserResource

func NewUserResource(
	ctx context.Context,
	user *User,
) register.UserResource

NewUserResource generates a new user resource.

Types

type ErrUniqueConstraintViolation

type ErrUniqueConstraintViolation struct {
	Err error
}

ErrUniqueConstraintViolation is returned when a object insertion violates a unique constraint.

func (ErrUniqueConstraintViolation) Error

type User

type User struct {
	Token   string
	Created time.Time

	Status   register.UsrStatus
	Username string
	Email    string

	Secret   string
	Password string

	MintToken *string `db:"mint_token"`
}

User represents a user object. Users are not tied to a mint user until they are verified.

func CreateUser

func CreateUser(
	ctx context.Context,
	username string,
	email string,
) (*User, error)

CreateUser creates and stores a new User object.

func LoadUserByUsername

func LoadUserByUsername(
	ctx context.Context,
	username string,
) (*User, error)

LoadUserByUsername attempts to load a user with the given username.

func (*User) RollPassword

func (u *User) RollPassword(
	ctx context.Context,
) error

RollPassword generates a new password for the user.

func (*User) Save

func (u *User) Save(
	ctx context.Context,
) error

Save updates the object database representation with the in-memory values.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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