database

package
v0.0.0-...-ccce489 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2021 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Instance *gorm.DB

Instance is a shared, global Gorm instance. Initialize with CreateInstance.

Functions

func ComputeHash

func ComputeHash(password string, salt []byte) []byte

ComputeHash computes a hash for a given password and salt combination.

func CreateInstance

func CreateInstance(connectionString string) error

CreateInstance creates a global Gorm instance.

func Migrate

func Migrate()

Migrate automatically creates the necessary database structure for all models.

Types

type User

type User struct {
	gorm.Model
	Username       string `gorm:"unique;index"`
	HashedPassword []byte
	PasswordSalt   []byte
}

User represents a single Okra user.

func NewUser

func NewUser(username, password string) (*User, error)

NewUser creates a new user.

func (*User) ChangePassword

func (user *User) ChangePassword(password string)

ChangePassword changes a user's password.

func (*User) CheckPassword

func (user *User) CheckPassword(password string) bool

CheckPassword checks a provided password against the stored password for a given user.

Jump to

Keyboard shortcuts

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