auth

package
v0.0.0-...-a114734 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CryptPassword

func CryptPassword(raw string) (string, error)

CryptPassword returns a password encrypted with bcrypt

func IsPasswordValid

func IsPasswordValid(hash string, raw string) bool

IsPasswordValid Compare a bcrypt hash with a raw string and check if they match

func SessionJoinSQL

func SessionJoinSQL(prefix string) string

SessionJoinSQL returns a string ready to be embed in a JOIN query

func UserExists

func UserExists(id string) (bool, error)

UserExists checks if a user exists for a specific ID

func UserJoinSQL

func UserJoinSQL(prefix string) string

UserJoinSQL returns a string ready to be embed in a JOIN query

Types

type Session

type Session struct {
	ID        string   `db:"id"`
	CreatedAt *db.Time `db:"created_at"`
	UpdatedAt *db.Time `db:"updated_at"`
	DeletedAt *db.Time `db:"deleted_at"`

	UserID string `db:"user_id"`
}

Session is a structure representing a session that can be saved in the database

func (*Session) Create

func (s *Session) Create() error

Create persists a session in the database

func (*Session) CreateQ

func (s *Session) CreateQ(q db.Queryable) error

CreateQ persists a session in the database

func (*Session) Delete

func (s *Session) Delete() error

Delete soft delete a session.

func (*Session) DeleteQ

func (s *Session) DeleteQ(q db.Queryable) error

DeleteQ soft delete a session using a transaction

func (*Session) Exists

func (s *Session) Exists() (bool, error)

Exists check if a session exists in the database

func (*Session) FullyDelete

func (s *Session) FullyDelete() error

FullyDelete removes a session from the database

func (*Session) FullyDeleteQ

func (s *Session) FullyDeleteQ(q db.Queryable) error

FullyDeleteQ removes a session from the database using a transaction

func (*Session) IsZero

func (s *Session) IsZero() bool

IsZero checks if the object is either nil or don't have an ID

func (*Session) Save

func (s *Session) Save() error

Save creates or updates the session depending on the value of the id

func (*Session) SaveQ

func (s *Session) SaveQ(q db.Queryable) error

SaveQ is an alias for Create since sessions are not updatable

type User

type User struct {
	ID        string   `db:"id"`
	CreatedAt *db.Time `db:"created_at"`
	UpdatedAt *db.Time `db:"updated_at"`
	DeletedAt *db.Time `db:"deleted_at"`

	Name     string `db:"name"`
	Email    string `db:"email"`
	Password string `db:"password"`
	IsAdmin  bool   `db:"is_admin"`
}

User is a structure representing a user that can be saved in the database

func GetUser

func GetUser(id string) (*User, error)

GetUser finds and returns an active user by ID

func (*User) Create

func (u *User) Create() error

Create persists a user in the database

func (*User) CreateQ

func (u *User) CreateQ(q db.Queryable) error

CreateQ persists a user in the database

func (*User) Delete

func (u *User) Delete() error

Delete soft delete a user.

func (*User) DeleteQ

func (u *User) DeleteQ(q db.Queryable) error

DeleteQ soft delete a user using a transaction

func (*User) FullyDelete

func (u *User) FullyDelete() error

FullyDelete removes a user from the database

func (*User) FullyDeleteQ

func (u *User) FullyDeleteQ(q db.Queryable) error

FullyDeleteQ removes a user from the database using a transaction

func (*User) IsZero

func (u *User) IsZero() bool

IsZero checks if the object is either nil or don't have an ID

func (*User) Save

func (u *User) Save() error

Save creates or updates the user depending on the value of the id

func (*User) SaveQ

func (u *User) SaveQ(q db.Queryable) error

SaveQ creates or updates the article depending on the value of the id using a transaction

func (*User) Update

func (u *User) Update() error

Update updates most of the fields of a persisted user. Excluded fields are id, created_at, deleted_at, etc.

func (*User) UpdateQ

func (u *User) UpdateQ(q db.Queryable) error

UpdateQ updates most of the fields of a persisted user. Excluded fields are id, created_at, deleted_at

Jump to

Keyboard shortcuts

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