auth

package
v0.0.0-...-494a29a Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorUserExists       = "user exists"
	ErrorWrongCredentials = "wrong credentials"
)

Variables

This section is empty.

Functions

func NewAuthHandler

func NewAuthHandler(router *http.ServeMux, deps AuthHandlerDeps)

Types

type AuthHandler

type AuthHandler struct {
	*configs.Config
	*AuthService
}

func (*AuthHandler) Login

func (handler *AuthHandler) Login() http.HandlerFunc

func (*AuthHandler) Register

func (handler *AuthHandler) Register() http.HandlerFunc

type AuthHandlerDeps

type AuthHandlerDeps struct {
	*configs.Config
	*AuthService
}

type AuthService

type AuthService struct {
	UserRepository di.IUserRepository
}

func NewAuthService

func NewAuthService(userRepository di.IUserRepository) *AuthService

func (*AuthService) Login

func (service *AuthService) Login(email, password string) (string, error)

func (*AuthService) Register

func (service *AuthService) Register(email, name, password string) (string, error)

type LoginRequest

type LoginRequest struct {
	Email    string `json:"email" validate:"required,email"`
	Password string `json:"password" validate:"required"`
}

type LoginResponse

type LoginResponse struct {
	Token string `json:"token"`
}

type RegisterRequest

type RegisterRequest struct {
	Email    string `json:"email" validate:"required,email"`
	Password string `json:"password" validate:"required"`
	Name     string `json:"name" validate:"required"`
}

type RegisterResponse

type RegisterResponse struct {
	Token string `json:"token"`
}

Jump to

Keyboard shortcuts

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