utils

package
v2.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckError added in v2.1.1

func CheckError(err error)

func CheckPassword

func CheckPassword(password string, hash string) bool

func CreateToken

func CreateToken(claims map[string]interface{}) (string, error)

func DeviceConnectMiddleware added in v2.1.1

func DeviceConnectMiddleware(w http.ResponseWriter, r *http.Request, accountID string) string

func GeneratePassword

func GeneratePassword(size int) string

func GetCurrentUserDevice added in v2.1.2

func GetCurrentUserDevice(w http.ResponseWriter, req *http.Request, accountID string) model.DeviceConnect

func GetDeviceName added in v2.1.1

func GetDeviceName(ip string) (string, error)

func GetDeviceNameWithIp added in v2.1.1

func GetDeviceNameWithIp(w http.ResponseWriter, r *http.Request) string

func GetIPAddress added in v2.1.1

func GetIPAddress(r *http.Request) string

func HashPassword

func HashPassword(password string) string

func NewTokenAuth

func NewTokenAuth() *jwtauth.JWTAuth

func VerifyToken

func VerifyToken(tokenString string) bool

func WriteError added in v2.1.1

func WriteError(w http.ResponseWriter, statusCode int, message string)

Types

type DeviceInfo added in v2.1.1

type DeviceInfo struct {
	IPAddress     string `json:"ip_address"`
	DeviceName    string `json:"device_name"`
	City          string `json:"city"`
	Country       string `json:"country"`
	OperationTime string `json:"operation_time"`
}

type DeviceInfoResponse added in v2.3.1

type DeviceInfoResponse struct {
	Os       string `json:"os"`
	Browser  string `json:"browser"`
	Location string `json:"location"`
}

func GetDeviceInfo added in v2.3.1

func GetDeviceInfo(req *http.Request) DeviceInfoResponse

type ErrorResponse added in v2.1.1

type ErrorResponse struct {
	Message string `json:"message"`
}

type IPInfoResponse added in v2.1.1

type IPInfoResponse struct {
	IP       string `json:"ip"`
	Hostname string `json:"hostname"`
	City     string `json:"city"`
	Region   string `json:"region"`
	Country  string `json:"country"`
	Loc      string `json:"loc"`
	Org      string `json:"org"`
	Postal   string `json:"postal"`
	Timezone string `json:"timezone"`
}

Jump to

Keyboard shortcuts

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