user

package
v0.0.0-...-dd92ee3 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package user holds the models related to users.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AreThereAnyUsers

func AreThereAnyUsers() bool

AreThereAnyUsers checks to see if the database has any users or not.

func GenerateInviteToken

func GenerateInviteToken(n int) string

GenerateInviteToken creates a token, n characters long, made up of the charactesr listed in the characters string above.

func InsertInvitation

func InsertInvitation(invite Invitation) error

InsertInvitation adds the provided invitation to the database.

func InviteEmailExists

func InviteEmailExists(email string) bool

InviteEmailExists returns true if an invite is already in the system.

func InviteTokenExists

func InviteTokenExists(token string) bool

InviteTokenExists returns true if an invite is already in the system.

func IsEmailUnique

func IsEmailUnique(email string) bool

IsEmailUnique lets you verify if a user exists in the database already. False means they are there.ss

func IsEmailValidated

func IsEmailValidated(address string) bool

IsEmailValidated returns the value of User.IsEmailValidated

func RemoveInvitation

func RemoveInvitation(token string) error

RemoveInvitation removes an invitation from the database.

func ValidatePassword

func ValidatePassword(password string) []string

ValidatePassword validates the offered user password.

func ValidateUserForm

func ValidateUserForm(newUser Form, isNew bool) []string

ValidateUserForm validates the data provided and returns a slice of strings if there are any errors. Its first argument is a filled in UserForm struct. This is the data to be validated/ Its second argument is a bool value declaring if the form is for a new user rather than just updating a user.

Types

type Form

type Form struct {
	Email    string
	Name     string
	Password string
}

Form is a struct to collect user data for validation.

type Invitation

type Invitation struct {
	ID    bson.ObjectId `bson:"_id,omitempty"`
	Email string
	Token string
}

Invitation is the model used when sending invitations to a user.

func InviteByToken

func InviteByToken(token string) (*Invitation, error)

InviteByToken retrieves an invitation from the database matching the given token.

func NewInvitation

func NewInvitation(email string) Invitation

NewInvitation accepts an email address and creates a new invitation.

type Profile

type Profile struct {
	Name string

	//Settings
	ItemsPerPage int
}

Profile is the model that will hold profile data

type User

type User struct {
	ID              bson.ObjectId `bson:"_id,omitempty"`
	Email           string
	Password        string
	IsAdmin         bool
	EmailIsVerified bool
	Timestamp       time.Time
	LastUpdated     time.Time
	Profile         Profile
}

User is the user model

func CreateUserFromForm

func CreateUserFromForm(newUser Form) *User

CreateUserFromForm creates a new user object from the data provided via a UserForm object.

func GetUserByEmail

func GetUserByEmail(email string) *User

GetUserByEmail grabs a user object from the database based on the email address.

func GetUsers

func GetUsers() []User

GetUsers returns a list of all the users in the database.

func (*User) Authenticate

func (user *User) Authenticate(password string) bool

Authenticate allows the login method to make sure we have the right person.

func (*User) SetPassword

func (user *User) SetPassword(password string)

SetPassword sets the password on the user object

Directories

Path Synopsis
Package userhandlers holds the handlers/views for the User mode.
Package userhandlers holds the handlers/views for the User mode.

Jump to

Keyboard shortcuts

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