users

package
v0.0.0-...-4e4842a Latest Latest
Warning

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

Go to latest
Published: May 4, 2016 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoginUser

func LoginUser(sess *sessions.Session, uR *UserRepository, username string, password string) (bool, error)

LoginUser tries to login a user using given credentials

func ValidateLogin

func ValidateLogin(username string, password string) error

ValidateLogin validates a user using given credentials

func ValidatePasswordChange

func ValidatePasswordChange(
	uR *UserRepository,
	user User,
	currentPassword string,
	newPassword string,
	passwordConfirmation string) error

ValidatePasswordChange validates a password change given current password, new password and confirmed password

func ValidateUpdate

func ValidateUpdate(uR *UserRepository, user User) error

ValidateUpdate validates the new values for a user

Types

type User

type User struct {
	gorm.Model
	Username  string
	Email     string
	Password  string
	FirstName string
	LastName  string
	// contains filtered or unexported fields
}

User model

type UserRepository

type UserRepository struct {
	Db database.Database
}

UserRepository type

func (*UserRepository) ByEmail

func (uR *UserRepository) ByEmail(email string) User

ByEmail returns a User object that has a given email address

func (*UserRepository) ByID

func (uR *UserRepository) ByID(usernameID uint) User

ByID returns a User object that has the provided id

func (*UserRepository) ByUsername

func (uR *UserRepository) ByUsername(username string) User

ByUsername returns a User object that has a given username

func (*UserRepository) NewUser

func (uR *UserRepository) NewUser(
	username string,
	firstName string,
	lastName string,
	email string,
	password string,
	passwordVerification string) (User, error)

NewUser creates validates input and creates a new user instance

func (*UserRepository) Save

func (uR *UserRepository) Save(user *User)

Save persists to database a User type

func (*UserRepository) Update

func (uR *UserRepository) Update(user *User) error

Update persists to database changes for a user model

Jump to

Keyboard shortcuts

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