users

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

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

Go to latest
Published: Apr 19, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCategoryNotFound = "Could not find category"
View Source
var ErrCouldNotFindReleases = "Could not find releases"
View Source
var ErrInsertRelease = "Error returned when inserting release"
View Source
var ErrInsertUser = errors.New("Error inserting user into DB")
View Source
var ErrStrDeleteUser = "Error returned when deleting user"
View Source
var ErrStrUpdateUser = "Error returned when updating user"
View Source
var ErrUserNotFound = errors.New("user not found")
View Source
var NoMgoSess = "nil pointer passed from session to mongo"

Functions

This section is empty.

Types

type Credentials

type Credentials struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

Credentials represents user sign-in credentials

type MgoStore

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

implements UserStore interface

func NewMgoStore

func NewMgoStore(sess *mgo.Session, dbName string, collectionName string) *MgoStore

func (*MgoStore) Delete

func (ms *MgoStore) Delete(id bson.ObjectId) error

func (*MgoStore) GetByEmail

func (ms *MgoStore) GetByEmail(email string) (*User, error)

func (*MgoStore) GetByID

func (ms *MgoStore) GetByID(id bson.ObjectId) (*User, error)

func (*MgoStore) Insert

func (ms *MgoStore) Insert(nu *NewUser) (*User, error)

type NewUser

type NewUser struct {
	Email        string `json:"email"`
	Password     string `json:"password"`
	PasswordConf string `json:"passwordConf"`
	FirstName    string `json:"firstName"`
	LastName     string `json:"lastName"`
}

NewUser represents a new user signing up for an account

func (*NewUser) ToUser

func (nu *NewUser) ToUser() (*User, error)

func (*NewUser) Validate

func (nu *NewUser) Validate() error

type User

type User struct {
	ID        bson.ObjectId `json:"id" bson:"_id"`
	Email     string        `json:"email"`
	PassHash  []byte        `json:"-"` //stored, but not encoded to clients
	FirstName string        `json:"firstName"`
	LastName  string        `json:"lastName"`
}

User represents a user account in the database

func (*User) Authenticate

func (u *User) Authenticate(password string) error

func (*User) FullName

func (u *User) FullName() string

func (*User) SetPassword

func (u *User) SetPassword(password string) error

type UserStore

type UserStore interface {
	//GetByID returns the User with the given ID
	GetByID(id bson.ObjectId) (*User, error)

	//GetByEmail returns the User with the given email
	GetByEmail(email string) (*User, error)

	//Insert converts the NewUser to a User, inserts
	//it into the database, and returns it
	Insert(newUser *NewUser) (*User, error)

	//Delete deletes the user with the given ID
	Delete(id bson.ObjectId) error
}

Jump to

Keyboard shortcuts

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