auth

package
v0.0.0-...-6907ca9 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2018 License: MIT Imports: 7 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JoinUserSQL

func JoinUserSQL(prefix string) string

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

func SessionJoinSQL

func SessionJoinSQL(prefix string) string

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

Types

type Session

type Session struct {
	ID        string             `db:"id"`
	CreatedAt *datetime.DateTime `db:"created_at"`
	UpdatedAt *datetime.DateTime `db:"updated_at"`
	DeletedAt *datetime.DateTime `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(q db.Queryable) error

Create persists a session in the database

func (*Session) Delete

func (s *Session) Delete(q sqldb.Queryable) error

Delete removes a session from the database

func (*Session) Exists

func (s *Session) Exists(q db.Queryable) (bool, error)

Exists check if a session exists in the database

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(q db.Queryable) error

Save is an alias for Create since sessions are not updatable

type User

type User struct {
	ID        string             `db:"id"`
	CreatedAt *datetime.DateTime `db:"created_at"`
	UpdatedAt *datetime.DateTime `db:"updated_at"`
	DeletedAt *datetime.DateTime `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 GetAnyUserByID

func GetAnyUserByID(q sqldb.Queryable, id string) (*User, error)

GetAnyUserByID finds and returns an user by ID. Deleted object are returned

func GetUserByID

func GetUserByID(q sqldb.Queryable, id string) (*User, error)

GetUserByID finds and returns an active user by ID Deleted object are not returned

func (*User) Create

func (u *User) Create(q sqldb.Queryable) error

Create persists a user in the database

func (*User) Delete

func (u *User) Delete(q sqldb.Queryable) error

Delete removes a user from the database

func (*User) IsAdm

func (u *User) IsAdm() bool

IsAdm checks if the user object belong to a logged in admin Works on nil object

func (*User) IsLogged

func (u *User) IsLogged() bool

IsLogged checks if the user object belong to a logged in user Works on nil object

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(q sqldb.Queryable) error

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

func (*User) Update

func (u *User) Update(q sqldb.Queryable) error

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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