util

package
v0.0.0-...-5b6618e Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ALERT_SUCCESS               = "Success"
	ALERT_NOT_FOUND             = "Not found"
	ALERT_TOKEN_NOT_FOUND       = "Your JWT token not found"
	ALERT_USER_CONFLICT         = "Someone registered with this email"
	ALERT_ORG_CONFLICT          = "Organization already created with this name"
	ALERT_CONFLICT              = "Conflict"
	ALERT_INVALID_EMAIL         = "Invalid email address"
	ALERT_INSECURE_PASSWORD     = "Insecure password"
	ALERT_LOGIN_UNAUTHORIZED    = "Your password or email address is invalid"
	ALERT_ORG_EDIT_UNAUTHORIZED = "You are not member of this organization"
	ALERT_BAD_REQUEST           = "Bad request"
	ALERT_REQUIRED_FIELDS       = "Your request is in complete. You should fill all required fields"
	ALERT_INVALID_TOKEN         = "Invalid JWT token"
	ALERT_BAD_FILE              = "Invalid file format"
	ALERT_STORY_WRONG           = "Wrong story field"
	ALERT_DUP_ESTORY            = "You can't create more that one explore story"
	ALERT_USER_ONLY             = "You should be user to access this page"
	ALERT_SUPER_ADMIN_ONLY      = "You should be super admin to access this page"
	ALERT_ADMIN_ONLY            = "You should be admin or super admin to access this page"
	ALERT_INTERNAL              = "Internal server error"
	ALERT_ASSIGN_ADMIN_TO_ORG   = "Invalid user or organization data"
)
View Source
const DATE_FORMAT = "2006-01-02"

Variables

View Source
var (
	SmtpAuth smtp.Auth
	SmtpConf config.SmtpConf
)
View Source
var EXPTIME = jwt.NewNumericDate(time.Now().Add(time.Hour * 24 * 30))

Functions

func CreateRandomString

func CreateRandomString(salt string, len uint) string

func CreateSHA256

func CreateSHA256(pass string) string

func CreateUserToken

func CreateUserToken(id uint, email, user, role string) string

func GetToken

func GetToken(c echo.Context) string

func GetUniqueName

func GetUniqueName(name string) string

func GetUserDir

func GetUserDir(id uint) string

func GetUserId

func GetUserId(c echo.Context) uint

func GetUserRole

func GetUserRole(c echo.Context) string

func InitMail

func InitMail(c config.SmtpConf)

func IsValidPath

func IsValidPath(pathname string, isImage bool) bool

func ParseBody

func ParseBody(c echo.Context, obj any, requireds []string, mustIgnore []string) error

Types

type Response

type Response struct {
	// say status of response.
	// false means to failure and true means to success.
	Status bool `json:"status" example:"true"`

	// message for client.
	Alert string `json:"alert" example:"suitable alert"`

	// will be null in case of status=false.
	// client needed data
	Data any `json:"data"`
}

Response model

type ResponseError

type ResponseError struct {
	// say status of response.
	// false means to failure and true means to success.
	Status bool `json:"status" example:"false"`

	// message for client.
	Alert string `json:"alert" example:"some error"`

	// Will be null.
	Data int `json:"data" example:"0"`
}

ReponseError model

type SmtpContent

type SmtpContent struct {
	Subject string `json:"subject"`
	Body    string `json:"body"`
}

Jump to

Keyboard shortcuts

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