database

package
v0.0.0-...-d9a73af Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Database controller struct holding database name database username and passwor port for database gets loaded on program startup from .env file

func NewController

func NewController(name, username, pw string, port int) *Controller

Create new database controller

func (*Controller) GetUserAfterLogin

func (c *Controller) GetUserAfterLogin(username string) (*datatypes.User, error)

fetch user by username from database returns pointer to user or error on failure

func (*Controller) OpenConnection

func (c *Controller) OpenConnection() (error, bool)

Open gorm database connection for accessing information Uses environment variables from controller creation returns nil, true on success, err, false otherwise

func (*Controller) PasswordMatches

func (c *Controller) PasswordMatches(user, pw string) (error, bool)

Check if password for user exists and matches the saved hash

func (*Controller) SaveNewUser

func (c *Controller) SaveNewUser(name, pw string) (error, bool)

Saves a user with password converts password to hash with custom salt

func (*Controller) UserExists

func (c *Controller) UserExists(name string) (error, bool)

check if user exists

Jump to

Keyboard shortcuts

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