users

package
v0.0.0-...-787a26c Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	INVALID  string = "INVALID"
	NONE     string = "NONE"
	GOOGLE   string = "GOOGLE"
	FACEBOOK string = "FACEBOOK"
	GITHUB   string = "GITHUB"
)
View Source
const (
	CLIENT string = "CLIENT"
	ADMIN  string = "ADMIN"
)

Variables

This section is empty.

Functions

func AdminAuthenticator

func AdminAuthenticator() func(http.Handler) http.Handler

func AdminRouter

func AdminRouter() http.Handler

func AuthRouter

func AuthRouter() http.Handler

func ConvertToAuthProvider

func ConvertToAuthProvider(provider string) string

func FailedAuthUser

func FailedAuthUser() common.APIError

func FailedCreation

func FailedCreation() common.APIError

func FailedFind

func FailedFind() common.APIError

func FailedGenerateAuthToken

func FailedGenerateAuthToken() common.APIError

func FailedLogout

func FailedLogout() common.APIError

func GetByIDHandler

func GetByIDHandler(w http.ResponseWriter, r *http.Request) error

func InvalidID

func InvalidID() common.APIError

func LoginHandler

func LoginHandler(w http.ResponseWriter, r *http.Request) error

func LogoutHandler

func LogoutHandler(w http.ResponseWriter, r *http.Request) error

func NewRepository

func NewRepository(ctx context.Context, conn *pgxpool.Pool)

func NewServer

func NewServer(repository *Repository)

func OnboardingRouter

func OnboardingRouter() http.Handler

func PrivateAuthenticator

func PrivateAuthenticator() func(http.Handler) http.Handler

func Provider

func Provider(w http.ResponseWriter, r *http.Request) error

func ProviderCallback

func ProviderCallback(w http.ResponseWriter, r *http.Request) error

func RegisterHandler

func RegisterHandler(w http.ResponseWriter, r *http.Request) error

func Router

func Router() http.Handler

Types

type Entity

type Entity struct {
	ID           uuid.UUID `db:"id"`
	Email        string    `db:"email"`
	Nickname     string    `db:"nickname"`
	Password     string    `db:"password"`
	AuthProvider string    `db:"auth_provider"`
	Role         string    `db:"role"`
	CreatedAt    time.Time `db:"created_at"`
	ModifiedAt   time.Time `db:"modified_at"`
}

func CreateEntityFromModel

func CreateEntityFromModel(model Model) Entity

type LoginRequestDTO

type LoginRequestDTO struct {
	Email        string `json:"email"`
	Nickname     string `json:"nickname"`
	Password     string `json:"password"`
	AuthProvider string `json:"auth_provider"`
}

type Model

type Model struct {
	ID           uuid.UUID
	Email        string
	Nickname     string
	Password     string
	AuthProvider string
	Role         string
	CreatedAt    time.Time
	ModifiedAt   time.Time
}

func CreateModelFromEntity

func CreateModelFromEntity(entity Entity) Model

func CreateModelFromLoginRequestDTO

func CreateModelFromLoginRequestDTO(requestDTO LoginRequestDTO) Model

func CreateModelFromRegisterRequestDTO

func CreateModelFromRegisterRequestDTO(requestDTO RegisterRequestDTO) Model

func (*Model) Validate

func (m *Model) Validate() error

type RegisterRequestDTO

type RegisterRequestDTO struct {
	Email        string `json:"email"`
	Nickname     string `json:"nickname"`
	Password     string `json:"password"`
	AuthProvider string `json:"auth_provider"`
}

type Repository

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

func GetRepository

func GetRepository() *Repository

func (*Repository) CreateEntity

func (r *Repository) CreateEntity(entity Entity) (Entity, error)

func (*Repository) DeleteEntity

func (r *Repository) DeleteEntity(id uuid.UUID) error

func (*Repository) GetEntityByEmail

func (r *Repository) GetEntityByEmail(email string, authProvider string) (Entity, error)

func (*Repository) GetEntityByID

func (r *Repository) GetEntityByID(id uuid.UUID) (Entity, error)

func (*Repository) UpdateEntity

func (r *Repository) UpdateEntity(entity Entity) (Entity, error)

UpdateEntity Only can update nickname and modified_at

type ResponseDTO

type ResponseDTO struct {
	ID       string `json:"id"`
	Email    string `json:"email"`
	Nickname string `json:"nickname"`
	Role     string `json:"role"`
}

func CreateResponseDTOFromModel

func CreateResponseDTOFromModel(model Model) ResponseDTO

type Server

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

func GetServer

func GetServer() *Server

func (*Server) Auth

func (s *Server) Auth(email string, provider string) (Model, error)

func (*Server) CreateModel

func (s *Server) CreateModel(model Model) (Model, error)

func (*Server) FindModelByEmailAndAuthProvider

func (s *Server) FindModelByEmailAndAuthProvider(model Model) (Model, error)

func (*Server) GetModelByID

func (s *Server) GetModelByID(id string) (Model, error)

func (*Server) InitAuthProviders

func (s *Server) InitAuthProviders()

func (*Server) UpdateModel

func (s *Server) UpdateModel(model Model) (Model, error)

Jump to

Keyboard shortcuts

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