user

package
v0.0.0-...-a633465 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoSuchUser = errors.New("no such user")
)

errors

Functions

This section is empty.

Types

type Gender

type Gender uint8

Gender is the user gender

const (
	// Undefined ?
	Undefined Gender = iota
	// Male male
	Male
	// Female female
	Female
)

type User

type User struct {
	ID         uint           `json:"id"`
	Username   string         `json:"username"`
	Email      string         `json:"email"`
	Password   string         `json:"-"`
	Firstname  string         `json:"firstname"`
	Lastname   string         `json:"lastname"`
	Gender     Gender         `json:"gender"`
	Address    string         `json:"address"`
	City       string         `json:"city"`
	State      string         `json:"state"`
	Zip        string         `json:"zip"`
	Country    string         `json:"country"`
	About      string         `json:"about"`
	Locale     string         `json:"locale"` // char(2)
	ShowNsfw   bool           `db:"show_nsfw" json:"show_nsfw"`
	UserURL    string         `db:"user_url" json:"user_url"`
	Admin      bool           `json:"admin"`
	AvatarURL  string         `db:"avatar_url" json:"avatar_url"`
	PublicKey  sql.NullString `db:"public_key" json:"public_key"`
	PrivateKey sql.NullString `db:"private_key" json:"-"`
	AuthUUID   sql.NullString `db:"authuuid" json:"-"`
}

User represent an user

func Create

func Create(email, username, clearPassword string) (user *User, err error)

Create creates and returns a new user

func GetByEmail

func GetByEmail(email string) (user *User, err error)

GetByEmail returns user by his email

func GetByID

func GetByID(id int) (user *User, err error)

GetByID return user by its ID

func GetByUsername

func GetByUsername(username string) (user *User, err error)

GetByUsername return user by its ID

func Login

func Login(login, password string) (user *User, err error)

Login returns user if exists

func (*User) Create

func (u *User) Create() error

Create save new user in DB

func (*User) Update

func (u *User) Update() error

Update update user in DB

Jump to

Keyboard shortcuts

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