api

package
v0.0.0-...-d0e7b85 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrForbidden when HTTP status 403 is given
	ErrForbidden = errors.New("you don't have permission to access this resource")

	// ErrMissingLoginValues indicates a user tried to authenticate without username or password
	ErrMissingLoginValues = errors.New("missing Username or Password")

	// ErrFailedAuthentication indicates authentication failed, could be faulty username or password
	ErrFailedAuthentication = errors.New("incorrect Username or Password")
)

Functions

func AuthMiddleware

func AuthMiddleware(svc accounts.Service) *jwt.GinJWTMiddleware

AuthMiddleware returns auth middleware

func InitRouter

func InitRouter(r *gin.RouterGroup, svc accounts.Service) *gin.RouterGroup

InitRouter register accounts API routes

Types

type LoginReq

type LoginReq struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

LoginReq defines User login credentials

type RegisterReq

type RegisterReq struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

RegisterReq defins User registration payload

type UserContext

type UserContext struct {
	ID       string
	Email    string
	Metadata accounts.Metadata
}

UserContext defines user object which we propagates throu the context After successful authentication object is avaiblable in *gin.Context as User

type UserHandler

type UserHandler interface {
	Singup(c *gin.Context)
	Get(c *gin.Context)
}

UserHandler specify methods for handling user requests

func NewHandler

func NewHandler(svc accounts.Service) UserHandler

NewHandler init new userHandler

Jump to

Keyboard shortcuts

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