user

package
v0.0.0-...-fc343d5 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package user is dedicated to reading and writing user data in Auth-Db. The User and AuthCredentials resource definitions and methods are below.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorEmailParameterInvalid    = errors.New("User.email must be a valid email address.")
	ErrorUserIDParameterInvalid   = errors.New("AuthCredentials.userID must be a valid userID.")
	ErrorPasswordParameterInvalid = errors.New("AuthCredentials.password must be a valid password.")
	ErrorUserRowNotCreated        = errors.New("Create failed to create one row in the user.Users table.")
)
View Source
var (
	EmailMinLength = 10
	EmailMaxLength = 128

	ErrorEmailShort = errors.New("Email too short.")
	ErrorEmailLong  = errors.New("Email too long.")
)
View Source
var (
	UserIDMinLength = 8
	UserIDMaxLength = 64

	ErrorUserIDShort        = errors.New("UserID too short.")
	ErrorUserIDLong         = errors.New("UserID too long.")
	ErrorUserIDInvalidRunes = errors.New("UserID may only consist of numbers and letters.")
)
View Source
var (
	PasswordMinLength = 8
	PasswordMaxLength = 64

	ErrorPasswordShort     = errors.New("Password too short.")
	ErrorPasswordLong      = errors.New("Password too long.")
	ErrorPasswordLowerCase = errors.New("Password does not contain a lowercase letter.")
	ErrorPasswordUpperCase = errors.New("Password does not contain an uppercase letter.")
	ErrorPasswordNumber    = errors.New("Password does not contain a number.")
	ErrorPasswordSpecChars = errors.New("Password does not contain a special character.")
)

Functions

func AuthDB

func AuthDB() *sql.DB

MomentDB returns a connection to the SQLSRV Moment-Db database.

func CheckEmail

func CheckEmail(email string) error

CheckEmail returns an error if email is invalid.

func CheckPassword

func CheckPassword(password string) error

CheckPassword returns an error if password is invalid.

func CheckUserID

func CheckUserID(userID string) error

CheckUserID returns an error if userID is invalid.

Types

type Client

type Client interface {
	Newer
	Creater
	Fetcher
	Err() error
}

type CreateFetcher

type CreateFetcher interface {
	Creater
	Fetcher
}

type Creater

type Creater interface {
	Create(*User, sq.BaseRunner)
}

type Fetcher

type Fetcher interface {
	Fetch(string, sq.BaseRunner) *User
}

type Newer

type Newer interface {
	NewUser(string, string, string) *User
}

type User

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

User references a unique user.Users row in the Moment-Db database.

func (*User) Err

func (u *User) Err() error

func (*User) Password

func (u *User) Password() (p string)

type UserClient

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

func (*UserClient) Create

func (uc *UserClient) Create(u *User, db sq.BaseRunner)

Create inserts a new row into the user.Users table in db.

func (*UserClient) Err

func (uc *UserClient) Err() error

Err returns the the error status of a User instance.

func (*UserClient) Fetch

func (uc *UserClient) Fetch(userID string, db sq.BaseRunner) (u *User)

Fetch selects a row from the user.Users table in db.

func (*UserClient) NewUser

func (uc *UserClient) NewUser(userID, email, password string) (u *User)

NewUser is a constructor of the User struct.

Jump to

Keyboard shortcuts

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