api

package
v0.0.0-...-c2ccda8 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Data folder structure:

appsalts
users/
    {id1}/
        kmdata/                # this is managed by keys manager
            keys
            passwordhashfile   # in the user's case, this file is redundant
            salts
        recordfile1            # these are encrypted with kmdata just above
        recordfile2
        ...
    {id2}/
        kmdata/
            keys
            passwordhashfile
            salts
        recordfile1
        recordfile2
        ...

The appsalts contains two salts:

saltcookie                 # the salt used to generate the keys used to
                           # sign the cookies
saltpassword               # the salt used to encrypt the passwords
                           # within the database

Index

Constants

This section is empty.

Variables

View Source
var ErrEmailAlreadyUsed = errors.New("email already used")
View Source
var ErrWrongIdentifiers = errors.New("wrong identifiers")

Functions

This section is empty.

Types

type API

type API struct {
	Usersdir string
	// contains filtered or unexported fields
}

func NewAPI

func NewAPI(dataroot string, ocrserver string) *API

func (*API) AddPayment

func (api *API) AddPayment(u *db.User, serializedpayment []byte) error

func (*API) Initialize

func (api *API) Initialize() error

Initialize creates all the required file (should only be run if they don't already exist)

func (*API) ListPayments

func (api *API) ListPayments(u *db.User) ([]Payment, error)

func (*API) Login

func (api *API) Login(email, password string) (*db.User, error)

Login adds the user to loggedusers

func (*API) Logout

func (api *API) Logout(user *db.User) error

Logout has nothing to do to log out someone from the api's point of view so we just at least check that the current user is valid

func (*API) Resume

func (api *API) Resume() error

Resume loads stuff from files to be ready to serve

func (*API) Scan

func (api *API) Scan(user *db.User, header *multipart.FileHeader, img image.Image) (*Payment, error)

Scan requires user just to make sure that only members use this expensive feature

func (*API) SignUp

func (api *API) SignUp(email, password string) (*db.User, error)

SignUp creates a new user

FIXME: this function can change the state of the application but still return an error. It needs to clean up after itself if that happens, because otherwise, we are left with a corrupted state

FIXME: this is extrememly inefficient. It reads all the user data into memory just to compare emails and possibly add one entry

type ErrInvalidPayment

type ErrInvalidPayment error

type Payment

type Payment map[string]interface{}

Jump to

Keyboard shortcuts

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