helpers

package
v0.0.0-...-4211b98 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2025 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildPaginationInfo

func BuildPaginationInfo(page, pageSize, totalCount int) models.PaginationInfo

BuildPaginationInfo creates a standard pagination info object

func BuildPaginationInfoWithSorting

func BuildPaginationInfoWithSorting(page, pageSize, totalCount int, sortBy, sortDirection string) models.PaginationInfo

BuildPaginationInfoWithSorting creates a standard pagination info object with sorting information

func CalculateTotalPages

func CalculateTotalPages(totalCount int, pageSize int) int

CalculateTotalPages calculates the total number of pages based on total count and page size

func CheckVATExists

func CheckVATExists(vat, entityType, excludeID string) (bool, error)

CheckVATExists checks if a VAT exists in the specified entity table

func GeneratePassword

func GeneratePassword() (string, error)

GeneratePassword generates a secure temporary password that passes our validation

func GetEffectiveUserID

func GetEffectiveUserID(user *models.User) string

GetEffectiveUserID returns the effective user ID for a user For Owner users without a local database ID, returns "owner" as a fallback identifier This is used for audit logging and tracking operations by Owner users

func GetPaginationAndSortingFromQuery

func GetPaginationAndSortingFromQuery(c *gin.Context) (int, int, string, string)

GetPaginationAndSortingFromQuery extracts page, pageSize, sortBy and sortDirection from query parameters

func GetPaginationFromQuery

func GetPaginationFromQuery(c *gin.Context) (int, int)

GetPaginationFromQuery extracts page and pageSize from query parameters

func GetPasswordRequirements

func GetPasswordRequirements() []string

GetPasswordRequirements returns a list of password requirements for user display

func GetSortingFromQuery

func GetSortingFromQuery(c *gin.Context) (string, string)

GetSortingFromQuery extracts sortBy and sortDirection from query parameters

func GetUserContextExtended

func GetUserContextExtended(c *gin.Context) (string, string, string, string)

GetUserContextExtended extracts user ID, organization ID, and role information from Gin context Returns userID, userOrgID, userOrgRole, userRole strings

func GetUserFromContext

func GetUserFromContext(c *gin.Context) (*models.User, bool)

GetUserFromContext extracts user context data from Gin context Returns user object and boolean indicating success

func HashSystemSecret

func HashSystemSecret(secret string) (string, error)

HashSystemSecret generates an Argon2id hash of the system secret The hash is stored in the PHC string format: $argon2id$v=19$m=65536,t=3,p=2$salt$hash

func ValidatePasswordStrength

func ValidatePasswordStrength(password string) (bool, []string)

ValidatePasswordStrength validates password strength with simple, clear rules Returns only the first error found to guide user step by step

func VerifySystemSecret

func VerifySystemSecret(secret, encodedHash string) (bool, error)

VerifySystemSecret verifies a system secret against an Argon2id hash Returns true if the secret matches the hash, false otherwise

Types

This section is empty.

Jump to

Keyboard shortcuts

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