lexserver

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2017 License: GPL-3.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateEmptyUserDB

func CreateEmptyUserDB(fName string) error

CreateEmptyUserDB is used to create an empty user database

Types

type User

type User struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
	//PasswordHash string `json:"password_hash"` // TODO Should not be part of User?
	Roles string `json:"roles"`
	DBs   string `json:"dbs"`
}

A User class for the user db

type UserDB

type UserDB struct {
	*sql.DB
	// contains filtered or unexported fields
}

UserDB : A user database

func InitUserDB

func InitUserDB(fName string) (UserDB, error)

InitUserDB is used to setup the initial user database

func (UserDB) Authorized

func (udb UserDB) Authorized(userName, password string) (bool, error)

Authorized is used to check if the password matches the specified user name

func (UserDB) DeleteUser

func (udb UserDB) DeleteUser(userName string) error

DeleteUser is used to delete a user from the database

func (UserDB) GetPasswordHash

func (udb UserDB) GetPasswordHash(userName string) (string, error)

GetPasswordHash returns the password_hash value for userName. If no such value is found, the empty string is returned (along with a non-nil error value)

func (UserDB) GetUserByName

func (udb UserDB) GetUserByName(name string) (User, error)

GetUserByName looks up the user with the specified name

func (UserDB) GetUsers

func (udb UserDB) GetUsers() ([]User, error)

GetUsers returns the users defined in the database

func (UserDB) InsertUser

func (udb UserDB) InsertUser(u User, password string) error

InsertUser is used to insert a user into the database

func (UserDB) Update

func (udb UserDB) Update(user User) error

Update updates the fields of User except for User.ID and User.Name. Zero valued fields (empty string) will be treated as acceptable values, and updated to the empty string in the DB.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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