users

package
v0.0.0-...-2127833 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Credentials

type Credentials struct {
	Email    string
	Password string
}

type Handler

type Handler interface {

	// Create handles a request to create a new user
	Create(w http.ResponseWriter, r *http.Request)

	// Update handles a request to update a user
	Update(w http.ResponseWriter, r *http.Request)

	// Delete handles a request to delete a user
	Delete(w http.ResponseWriter, r *http.Request)

	// Me handles a request to get the current user
	Me(w http.ResponseWriter, r *http.Request)

	// Login handles a request to login a user
	Login(w http.ResponseWriter, r *http.Request)

	// Verify handles a request to verify a user
	Verify(w http.ResponseWriter, r *http.Request)
}

Handler provides the users handlers

func NewUsersHandler

func NewUsersHandler(i *do.Injector) (Handler, error)

NewUsersHandler creates a new users handler

type Service

type Service interface {
	// CreateUser creates a new user
	CreateUser(u *Users) error

	// UpdateUser updates a user
	UpdateUser(id string, u *Users) error

	// DeleteUser deletes a user
	DeleteUser(id string) error

	// GetMe returns the current user using JWKS token
	GetMe(id string) (*Users, error)

	// LoginUser logs in a user
	LoginUser(email string, password string) (string, error)

	// VerifyUser verifies a user
	VerifyUser(token string) error
}

Service is the users service interface

func NewUsersService

func NewUsersService(i *do.Injector) (Service, error)

NewUsersService creates a new users service

type Users

type Users struct {
	gorm.Model
	ID            uuid.UUID `gorm:"primaryKey"`
	FirstName     string    `gorm:"not null"`
	LastName      string    `gorm:"not null"`
	Address       string
	Email         string `gorm:"not null, unique"`
	EmailVerified bool   `gorm:"default:false"`
	Password      string `gorm:"not null"`
	WalletAddress string
}

func (*Users) BeforeCreate

func (u *Users) BeforeCreate(tx *gorm.DB) (err error)

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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