auth

package
v0.0.0-...-7e7559a Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authorize

func Authorize(s *Service) echo.MiddlewareFunc

func BackDoor

func BackDoor(cfg *config.Config, s *Service) echo.MiddlewareFunc

func ExpireCookie

func ExpireCookie() *http.Cookie

ExpireCookie creates a new cookie with Expires set to now

func NewCookie

func NewCookie(token string) *http.Cookie

NewCookie creates a new auth cookie with an expiry length of 1 year

Types

type HTTPServer

type HTTPServer struct {
	Service *Service
}

func NewHTTPServer

func NewHTTPServer(svc *Service) *HTTPServer

func (*HTTPServer) RouteTo

func (h *HTTPServer) RouteTo(e *echo.Echo, auth echo.MiddlewareFunc)

type Model

type Model struct {
	ID                int       `json:"id" db:"id"`
	Email             string    `json:"email" db:"email"`
	EncryptedPassword string    `json:"-" db:"encrypted_password"`
	RememberToken     string    `json:"-" db:"remember_token"`
	ConfirmationToken string    `json:"-" db:"confirmation_token "`
	UpdatedAt         time.Time `json:"updated_at" db:"updated_at"`
	CreatedAt         time.Time `json:"created_at" db:"created_at"`
}

Model is a struct that represents the user data

type Service

type Service struct {
	DB *sqlx.DB
}

func NewService

func NewService(db *sqlx.DB) *Service

func (*Service) CreateUser

func (s *Service) CreateUser(ctx context.Context, email, pass string) (*Model, error)

func (*Service) GetUser

func (s *Service) GetUser(ctx context.Context, email string) (*Model, error)

func (*Service) Login

func (s *Service) Login(ctx context.Context, email string, password string) (*Model, error)

func (*Service) ResetPassword

func (s *Service) ResetPassword(ctx context.Context, token string) error

func (*Service) SignOut

func (s *Service) SignOut(ctx context.Context, token string) error

func (*Service) UpdatePassword

func (s *Service) UpdatePassword(ctx context.Context, id, token, password string) error

func (*Service) Validate

func (s *Service) Validate(ctx context.Context, token string) error

Jump to

Keyboard shortcuts

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