db

package
v0.0.0-...-ccfc631 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	*gorm.DB
}

Conn maintains a connection to the database.

func New

func New(dataDir string) (*Conn, error)

New attempts to connect to or create the database.

func (*Conn) Close

func (c *Conn) Close()

Close closes the database connection.

type Host

type Host struct {
	ID   int64  `gorm:"primaryKey" json:"id"`
	Name string `gorm:"not null" json:"name"`
	Addr string `gorm:"not null" json:"addr"`
}

Host represents an SMTP server that can send email.

type User

type User struct {
	ID       int64  `gorm:"primaryKey" json:"id"`
	Email    string `gorm:"not null;uniqueIndex" json:"email"`
	Password string `gorm:"not null" json:"-"`
}

User corresponds to a user that can login to the admin page.

func (*User) Authenticate

func (u *User) Authenticate(password string) error

Authenticate compares the provided password to the one stored in the database. An error is returned if the values do not match.

func (*User) SetPassword

func (u *User) SetPassword(password string) error

SetPassword salts and hashes the user's password. It does not store the new value in the database.

Jump to

Keyboard shortcuts

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