auth

package
v0.4.9-no-login-entrop... Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidatePassword

func ValidatePassword() fiber.Handler

Types

type AuthService

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

AuthService allows dependency injection for the controller methods, so that the db connection needn't be created in the controller methods

func NewAuthService

func NewAuthService(conf *cfg.Config, ms *models.MemberStorage) *AuthService

NewAuthService creates an instance of the AuthService struct and returns a pointer to it It should be used within the routes package where the db connection and config are passed from the main package

func (*AuthService) Login

func (a *AuthService) Login(c *fiber.Ctx) error

TODO: verify if the database connection can be passed in as a parameter

func (*AuthService) Register

func (a *AuthService) Register(c *fiber.Ctx) error

Register handles the creation of a new user

type LoginInput

type LoginInput struct {
	Email      string `json:"email"`
	MemberName string `json:"membername"`
	Password   string `json:"password"`
}

LoginInput is the input for the login request

func (LoginInput) Validate

func (l LoginInput) Validate() (*models.MemberInput, error)

type RegLoginInput

type RegLoginInput interface {
	RegisterInput | LoginInput
}

RegLoginInput is an union (feature introduced in Go 1.18) of RegisterInput and LoginInput

type RegisterInput

type RegisterInput struct {
	Email           string `json:"email"`
	MemberName      string `json:"membername"`
	Password        string `json:"password"`
	PasswordConfirm string `json:"passwordConfirm"`
}

RegisterInput is the input for the registration request

func (RegisterInput) Validate

func (r RegisterInput) Validate() (*models.MemberInput, error)

type Validator

type Validator interface {
	Validate() (*models.MemberInput, error)
}

Jump to

Keyboard shortcuts

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