internal

package
v0.0.0-...-cb4582e Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingIsDirectoryField = errors.New("isDirectory field required")
	ErrMissingFileField        = errors.New("file field required")

	ErrNotADirectory         = errors.New("not a directory")
	ErrUsernameAlreadyExists = errors.New("username already exists")
	ErrDoesNotExist          = errors.New("user does not exist")

	ErrEmailAlreadyExists = errors.New("email already exists")

	ErrCouldNotGeneratePasswordHash = errors.New("could not generate password hash")

	ErrUnauthorized    = errors.New("unauthorized")
	ErrMustNotBeAuthed = errors.New("you must not be authed")
	ErrMustBeAuthed    = errors.New("you must be authed")
)

Functions

func CompareHashAndPassword

func CompareHashAndPassword(password, hashedPassword string) bool

func GenerateDatabaseDSN

func GenerateDatabaseDSN(config *Config) string

func GenerateJwtToken

func GenerateJwtToken(jwtSecret string, expires time.Duration, user *entities.User) (string, error)

func GeneratePasswordHash

func GeneratePasswordHash(password string) (string, error)

func GetLoggerInstance

func GetLoggerInstance() *log.Logger

func IsUserAdmin

func IsUserAdmin(user *entities.User) bool

func IsUserAuthed

func IsUserAuthed(user *entities.User) bool

func VerifyToken

func VerifyToken(tokenString, jwtSecret string) (*jwt.Token, error)

Types

type Config

type Config struct {
	DbHost     string
	DbPort     string
	DbUser     string
	DbName     string
	DbPassword string

	CookieLifetime int
	JwtSecret      string

	ServerHost string
	ServerPort string

	Path string
}

func NewConfig

func NewConfig() *Config

type ContentManagementService

type ContentManagementService interface {
	ReadDirectoryEntries(urlPath string) ([]*models.Entry, error)
	GetFilePath(urlPath string) string
}

type Database

type Database struct {
	Conn *gorm.DB
}

func ConnectToPSQL

func ConnectToPSQL(dsn string) (*Database, error)

func (*Database) AutoMigrate

func (db *Database) AutoMigrate(dst ...interface{}) error

type Repositories

type Repositories struct {
	UserRepository UserRepository
}

type Services

type Services struct {
	UserService              UserService
	ContentManagementService ContentManagementService
}

type UserRepository

type UserRepository interface {
	CreateUser(user *entities.User) error

	GetUserByID(id uint) (*entities.User, error)
	GetUserByEmail(email string) (*entities.User, error)
	GetUserByUsername(username string) (*entities.User, error)

	DeleteUser(user *entities.User) error
}

type UserService

type UserService interface {
	CreateUser(user *entities.User) error

	GetUserByID(id uint) (*entities.User, error)
	GetUserByEmail(email string) (*entities.User, error)
	GetUserByUsername(username string) (*entities.User, error)

	DeleteUser(user *entities.User) error
}

Jump to

Keyboard shortcuts

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