models

package
v0.0.0-...-3bfc28e Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNameEmpty = errors.New("Name is empty")
)
View Source
var (
	ErrUserNameIllegal = errors.New("User name contains illegal characters")
)

Functions

func CreateUser

func CreateUser(d mongo.Database, u *User) (err error)

CreateUser creates record of a new user.

func IsErrNameCharsNotAllowed

func IsErrNameCharsNotAllowed(err error) bool

IsErrNameCharsNotAllowed checks if an error is an ErrNameCharsNotAllowed.

func IsErrNamePatternNotAllowed

func IsErrNamePatternNotAllowed(err error) bool

func IsErrNameReserved

func IsErrNameReserved(err error) bool

IsErrNameReserved checks if an error is a ErrNameReserved.

func IsErrUserAlreadyExist

func IsErrUserAlreadyExist(err error) bool

IsErrUserAlreadyExist checks if an error is a ErrUserAlreadyExists.

func IsUsableUsername

func IsUsableUsername(name string) error

Types

type ErrNameCharsNotAllowed

type ErrNameCharsNotAllowed struct {
	Name string
}

func (ErrNameCharsNotAllowed) Error

func (err ErrNameCharsNotAllowed) Error() string

type ErrNamePatternNotAllowed

type ErrNamePatternNotAllowed struct {
	Pattern string
}

func (ErrNamePatternNotAllowed) Error

func (err ErrNamePatternNotAllowed) Error() string

type ErrNameReserved

type ErrNameReserved struct {
	Name string
}

func (ErrNameReserved) Error

func (err ErrNameReserved) Error() string

type ErrUserAlreadyExist

type ErrUserAlreadyExist struct {
	Name string
}

func (ErrUserAlreadyExist) Error

func (err ErrUserAlreadyExist) Error() string

type User

type User struct {
	ID        primitive.ObjectID `bson:"_id"`
	Username  string             `bson:"username"`
	Password  string             `bson:"password"`
	Email     string             `bson:"email"`
	FirstName string             `bson:"firstName"`
	LastName  string             `bson:"lastName"`
	LastLogin time.Time          `bson:"lastLogin"`
}

User represents a user in the database

func (*User) APIFormat

func (u *User) APIFormat() *api.User

func (*User) FullName

func (u *User) FullName() string

FullName returns the full name of the user

func (*User) HashPassword

func (u *User) HashPassword(passwd string)

func (*User) SetLastLogin

func (u *User) SetLastLogin()

func (*User) ValidatePassword

func (u *User) ValidatePassword(passwd string) bool

type UserList

type UserList []*User

func GetUsers

func GetUsers(d *mongo.Database) (UserList, error)

Jump to

Keyboard shortcuts

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