user

package module
v0.0.0-...-f60ed15 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2019 License: MIT Imports: 8 Imported by: 2

Documentation

Overview

Package user handles a user database.

Index

Constants

View Source
const (
	// HashLength defines the lenght of the password hash.
	HashLength = 64
	// SaltLength defines the length of the salt.
	SaltLength = 32
)
View Source
const Name = "users"

Name of the table

Variables

This section is empty.

Functions

func AuthenticateUser

func AuthenticateUser(db database.DB, user User, password string) error

func CreateTable

func CreateTable(db database.DB) error

CreateTable creates the users table.

func DeleteUserByID

func DeleteUserByID(db database.DB, id int64) error

func SetUserPassword

func SetUserPassword(db database.DB, user User, password string) error

func UpdateUser

func UpdateUser(db database.DB, user User) error

Types

type User

type User struct {
	Name      string `json:"name"`
	Email     string `json:"email"`
	Institute string `json:"institute"`
	ID        int64  `json:"id"`
	Admin     bool   `json:"admin"`
}

func All

func All(db database.DB) ([]User, error)

All returns all users in the database.

func FindByEmail

func FindByEmail(db database.DB, email string) (User, bool, error)

func FindByID

func FindByID(db database.DB, id int64) (User, bool, error)

func New

func New(db database.DB, user User) (User, error)

func (User) String

func (u User) String() string

Jump to

Keyboard shortcuts

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