user

package
v0.0.0-...-bdf6f31 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2021 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Session

type Session struct {
	ID        int64     // record ID of session
	UUID      string    // session UUID
	UserID    string    // relevant user UUID
	CreatedTs time.Time // created timstamp of session
}

Session structure

func (*Session) Check

func (session *Session) Check(db *sql.DB) (valid bool, err error)

Check whether the session is valid

func (*Session) Delete

func (session *Session) Delete(db *sql.DB) (err error)

Delete time-out or finished session

func (*Session) User

func (session *Session) User(db *sql.DB) (user User, err error)

User queries the user correspondint to the session

type User

type User struct {
	ID        int64     // record ID in database
	UUID      string    // user UUID
	Email     string    // user e-mail
	Name      string    // user name
	Password  string    // user password
	CreatedTs time.Time // created timstamp of user
}

User structure

func Get

func Get(db *sql.DB, uuid string) (user User, err error)

Get an existing user with given uuid

func GetUserByEmail

func GetUserByEmail(db *sql.DB, email string, pw string) (user User, err error)

GetUserByEmail --- get a user by using email and password

func New

func New(db *sql.DB, name string, email string, password string) (user User, err error)

New creates a new user with given name, email and password

func Users

func Users(db *sql.DB) (users []User, err error)

Users --- get all users

func (*User) ChangePassword

func (user *User) ChangePassword(db *sql.DB, curPw string, newPw string) (err error)

ChangePassword --- change user password

func (*User) Delete

func (user *User) Delete(db *sql.DB) (err error)

Delete an existing user

func (*User) Fetch

func (user *User) Fetch(db *sql.DB) (err error)

Fetch user info by using uuid

func (*User) Session

func (user *User) Session(db *sql.DB) (session Session, err error)

Session queries the last session of the user

func (*User) StartSession

func (user *User) StartSession(db *sql.DB) (session Session, err error)

StartSession creates a new session for the user

func (*User) Update

func (user *User) Update(db *sql.DB) (err error)

Update user name and email

Jump to

Keyboard shortcuts

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