utils

package
v0.0.0-...-9336d3e Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertInterfaceToSlice

func ConvertInterfaceToSlice(slice interface{}) []interface{}

ConvertInterfaceToSlice to convert interface to slice interface

func ConvertInterfaceToStringSlice

func ConvertInterfaceToStringSlice(slice interface{}) []string

ConvertInterfaceToStringSlice to convert interface to string slice

func CreateFile

func CreateFile(filePath string, content string) error

CreateFile creates a file on given path with given content

func CreateFolder

func CreateFolder(dir string) (string, error)

CreateFolder creates a folder in Current working dir

func DecryptNonce

func DecryptNonce(nonceHash string) (string, error)

DecryptNonce nonce string

func DeleteFromArray

func DeleteFromArray(original, valuesToDelete []string) []string

DeleteFromArray will delete array from an array

func EncryptNonce

func EncryptNonce(nonce string) (string, error)

EncryptNonce nonce string

func FindDeletedValues

func FindDeletedValues(original, updated []string) []string

FindDeletedValues find deleted values between original and updated one

func GenerateCodeChallenge

func GenerateCodeChallenge() (string, string)

GenerateCodeChallenge creates PKCE-Code-Challenge and returns the verifier and challenge

func GenerateNonce

func GenerateNonce() (string, string, error)

GenerateNonce generats random nonce string and returns the nonce string, nonce hash, error

func GenerateOTP

func GenerateOTP() string

GenerateOTP to generate random 6 digit otp

func GenerateTOTPRecoveryCode

func GenerateTOTPRecoveryCode() string

GenerateTOTPRecoveryCode generates a random 16-character recovery code.

func GetEmailVerificationURL

func GetEmailVerificationURL(token, hostname, redirectURI string) string

GetEmailVerificationURL to get url for invite email verification

func GetForgotPasswordURL

func GetForgotPasswordURL(token, redirectURI string) string

GetForgotPasswordURL to get url for given token and hostname

func GetIP

func GetIP(r *http.Request) string

GetIP helps in getting the IP address from the request

func GetInviteVerificationURL

func GetInviteVerificationURL(verificationURL, token, redirectURI string) string

GetInviteVerificationURL to get url for invite email verification

func GetOrganization

func GetOrganization() map[string]interface{}

GetOrganization to get organization object

func GetPagination

func GetPagination(paginatedInput *model.PaginatedInput) *model.Pagination

GetPagination helps getting pagination data from paginated input also returns default limit and offset if pagination data is not present

func GetUserAgent

func GetUserAgent(r *http.Request) string

GetUserAgent helps in getting the user agent from the request

func GinContextFromContext

func GinContextFromContext(ctx context.Context) (*gin.Context, error)

GinContext to get gin context from context

func HandleRedirectORJsonResponse

func HandleRedirectORJsonResponse(c *gin.Context, httpResponse int, response map[string]interface{}, redirectURL string)

HandleRedirectORJsonResponse handles the response based on redirectURL

func ParseDurationInSeconds

func ParseDurationInSeconds(s string) (time.Duration, error)

ParseDurationInSeconds parses input s, removes ms/us/ns and returns result duration

func RegisterEvent

func RegisterEvent(ctx context.Context, eventName string, authRecipe string, user *models.User) error

RegisterEvent util to register event TODO change user to user ref

func RemoveDuplicateString

func RemoveDuplicateString(strSlice []string) []string

RemoveDuplicateString removes duplicate strings from a string slice

func StringSliceContains

func StringSliceContains(s []string, e string) bool

StringSliceContains checks if a string slice contains a particular string

Types

This section is empty.

Jump to

Keyboard shortcuts

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