mysqldb

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddSettings

func AddSettings() (*uuid.UUID, error)

func AddUser

func AddUser(name string, email string, passwd string) error

AddUser creates a new user entry in the DB. Whitespaces in the email are automatically deleted Email is a unique attribute, so the function checks for existing email, before adding a new entry

func BootstrapSystem

func BootstrapSystem() error

func CheckEmailAndPassword

func CheckEmailAndPassword(email string, password string) error

CheckPassword compares the password entered by the user with the stored password.

func ConnectSystem

func ConnectSystem() (*sql.DB, error)

func DeleteSettings

func DeleteSettings(settingsID *uuid.UUID) error

func DeleteUser

func DeleteUser(email string) error

func EmailExists

func EmailExists(email string) (bool, error)

func GetUserCount

func GetUserCount() (int, error)

func UserExists

func UserExists(username string) (bool, error)

Types

type User

type User struct {
	ID         uuid.UUID `json:"id,omitempty"`
	Name       string    `json:"name,omitempty"`
	Email      string    `json:"email,omitempty"`
	Password   string    `json:"password,omitempty"`
	SettingsID uuid.UUID `json:"user_settings_id,omitempty"`
}

User defines the user structures. Each user must have an associated settings entry.

func GetUserByEmail

func GetUserByEmail(email string) (User, error)

GetUserByEmail returns the user defined by the email and password.

type UserSettings

type UserSettings struct {
	ID                uuid.UUID `json:"id,omitempty"`
	Enable2StepsVerif bool      `json:"two_steps_verif,omitempty"`
}

func GetSettings

func GetSettings(settingsID *uuid.UUID) (*UserSettings, error)

Jump to

Keyboard shortcuts

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