user

package
v0.0.0-...-31ad618 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Unlicense Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWrongCredentials = errors.New("wrong credentials")

Functions

func InitSession

func InitSession(db *sql.DB)

func Logout

func Logout(key session.Key) error

func Register

func Register(ctx context.Context, username, password string, privileges flag.Flag) error

func SetPrivileges

func SetPrivileges(q db.Q, id ID, privilege flag.Flag) error

Types

type ID

type ID = int

type Message

type Message struct {
	ID MessageID

	Sender    User
	Recipient User

	Title string
	Body  string

	Date timestamp.Timestamp
}

type MessageID

type MessageID int

type Profile

type Profile struct {
	User
	Title string
}

type User

type User struct {
	ID     ID
	Name   string
	Joined timestamp.Timestamp
	Flag   flag.Flag
}

func FromID

func FromID(ctx context.Context, id ID) (User, error)

func FromSession

func FromSession(ctx context.Context, key session.Key) (user User, err error)

func Login

func Login(ctx context.Context, username, password string) (key session.Key, user User, err error)

func (User) Profile

func (user User) Profile(ctx context.Context) (Profile, error)

func (*User) Scan

func (u *User) Scan(value any) (err error)

type UserSession

type UserSession struct {
	Key    session.Key
	Expire timestamp.Timestamp
}

func ActiveSessions

func ActiveSessions(id ID) ([]UserSession, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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