database

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2019 License: GPL-2.0 Imports: 13 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(user, password, dbname string)

func Init

func Init() error

func Initialized

func Initialized() bool

Types

type MagicLink struct {
	ID int64 `json:"id"`
	// Read: SERVER
	// Write: Nobody
	UserID int64 `json:"userid"`
	// Read: SERVER
	// Write: SERVER
	Magic string `json:"magic"`
}
func (ml *MagicLink) CreateMagicLink() res.ServerError

func (*MagicLink) DeleteMagicLinkFromMagicString

func (ml *MagicLink) DeleteMagicLinkFromMagicString() res.ServerError

func (*MagicLink) GetMagicLinkFromMagicString

func (ml *MagicLink) GetMagicLinkFromMagicString() res.ServerError

func (*MagicLink) ScanAll

func (ml *MagicLink) ScanAll(row *sql.Row) error

scans all user data into the user struct

type Scope

type Scope struct {
	ID          int64   `json:"id"`
	Name        *string `json:"name"`
	Description *string `json:"description"`
}

func CreateScope

func CreateScope(name, description string) (res.ServerError, *Scope)

type User

type User struct {
	// PUBLIC < USER == ADMINUSER < ADMIN < SERVER
	ID int64 `json:"id"`
	// Read: PUBLIC
	// Write: Nobody
	Name *string `json:"name,omitempty"`
	// Read: PUBLIC
	// Write: USER (offensive names, all included due to offensive names)
	Password *string `json:"password,omitempty"`
	// Read: SERVER
	// Write: USER or SERVER
	Email *string `json:"email,omitempty"`
	// Read: USER
	// Write: USER or SERVER
	Country *string `json:"country,omitempty"`
	// Read: PUBLIC
	// Write: USER or SERVER
	Locale *string `json:"locale,omitempty"`
	// Read: PUBLIC
	// Write: USER or SERVER
	DateCreated *time.Time `json:"date_created,omitempty"`
	// Read: PUBLIC
	// Write: Nobody (This is only ever set on creation.)
	Verified *bool `json:"verified,omitempty"`
	// Read: PUBLIC
	// Write: Nobody (by logging into sql only)
	Banned *bool `json:"banned,omitempty"`
	// Read: PUBLIC
	// Write: ADMIN only
	Admin *bool `json:"admin,omitempty"`
	// Read: PUBLIC
	// Write: Nobody (by logging into sql only)
	LastToken *string `json:"last_token,omitempty"` // ? is this needed
	// Read: SERVER
	// Write: SERVER
	LastLogin *time.Time `json:"last_login,omitempty"`
	// Read: PUBLIC
	// Write: SERVER
	LastIP *string `json:"last_ip,omitempty"`
	// Read: ADMIN
	// Write: SERVER
	Deleted *bool `json:"deleted,omitempty"`
	// READ: ADMIN
	// WRITE: USER (if false) Nobody (if true [sql only])
	DateDeleted *time.Time `json:"date_deleted,omitempty"`
	// READ: ADMIN
	// WRITE: SERVER
	UUID *string `json:"uuid"`
}

func (*User) CleanDataRead

func (u *User) CleanDataRead(auth authentication.Level)

applies read user data permissions of a fully retrieved user

func (*User) CreateToken

func (u *User) CreateToken() (string, error)

func (*User) CreateUser

func (u *User) CreateUser() res.ServerError

func (*User) DeleteUser

func (u *User) DeleteUser() res.ServerError

func (*User) GetUser

func (u *User) GetUser(auth authentication.Level) res.ServerError

func (*User) GetUserByEmail

func (u *User) GetUserByEmail(auth authentication.Level) res.ServerError

func (*User) GetUserByName

func (u *User) GetUserByName(auth authentication.Level) res.ServerError

func (*User) ScanAll

func (u *User) ScanAll(row *sql.Row) error

scans all user data into the user struct

func (*User) ScanAlls

func (u *User) ScanAlls(rows *sql.Rows) error

scans all user data into the user struct (for rows)

func (*User) ToString

func (u *User) ToString() string

literally for just debugging

func (*User) UnflagDeletion

func (u *User) UnflagDeletion() res.ServerError

func (*User) UpdateUser

func (u *User) UpdateUser(auth authentication.Level) res.ServerError

type UserList

type UserList struct {
	StartIndex int    `json:"startIndex"`      // starting index
	TotalItems int    `json:"totalItems"`      // how many items are returned
	Users      []User `json:"users,omitempty"` // user array
}

func GetUsers

func GetUsers(start, count int, auth authentication.Level) (*UserList, res.ServerError)

Jump to

Keyboard shortcuts

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