Back to godoc.org

Package utils

v0.0.0-...-49a3dec
Latest Go to latest

The latest major version is .

Published: Jul 4, 2020 | License: Apache-2.0 | Module: github.com/shopicano/shopicano-backend

Index

Constants

const (
	PasswordCost = 11

	StoreID         = "store_id"
	StorePermission = "store_permission"
	StoreStatus     = "store_status"
	UserID          = "user_id"
	UserPermission  = "user_permission"
	UserStatus      = "user_status"
	Scope           = "user_scope"
)
const (
	DateTimeFormat                = time.RFC3339
	DateTimeFormatForDistribution = "Mon Jan/02/2006 15:04:05"
	DateTimeFormatForInput        = "02-01-2006T15:04"
	DateFormat                    = "02-01-2006"
)

func BuildJWTToken

func BuildJWTToken(userID string, scope UserScope) (string, error)

func CheckPassword

func CheckPassword(hash, password string) error

func GeneratePassword

func GeneratePassword(password string) (string, error)

func GetStoreID

func GetStoreID(ctx echo.Context) string

func GetStorePermission

func GetStorePermission(ctx echo.Context) models.Permission

func GetStoreStatus

func GetStoreStatus(ctx echo.Context) models.StoreStatus

func GetUserID

func GetUserID(ctx echo.Context) string

func GetUserPermission

func GetUserPermission(ctx echo.Context) models.Permission

func GetUserStatus

func GetUserStatus(ctx echo.Context) models.UserStatus

func IntToDecimal

func IntToDecimal(v int, div int) (*braintree.Decimal, error)

func IsImage

func IsImage(name string) bool

func IsPlatformAdmin

func IsPlatformAdmin(ctx echo.Context) bool

func IsStoreStaff

func IsStoreStaff(ctx echo.Context) bool

func NewShortUUID

func NewShortUUID() string

func NewToken

func NewToken() string

func NewUUID

func NewUUID() string

func ParseBearerToken

func ParseBearerToken(ctx echo.Context) (string, error)

func ParseDateTimeForInput

func ParseDateTimeForInput(v string) (time.Time, error)

type Claims

type Claims struct {
	UserID string `json:"user_id"`
	jwt.StandardClaims
}

type UserScope

type UserScope string
const (
	Platform   UserScope = "platform"
	BackStore  UserScope = "back_store"
	FrontStore UserScope = "front_store"
)

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier