utils

package
v0.0.0-...-56fc341 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

func HashPassword

func HashPassword(password string) (string, error)

func InitOtpExpiryIndex

func InitOtpExpiryIndex(collection *mongo.Collection) error

func ValidateToken

func ValidateToken(token string, secretKey string) (*jwt.Token, error)

Types

type AccessDetails

type AccessDetails struct {
	AccessUuid string
	UserId     primitive.ObjectID
}

func ExtractTokenDetails

func ExtractTokenDetails(token *jwt.Token) (*AccessDetails, error)

type EmailManager

type EmailManager struct {
	SenderEmail string
	SenderName  string
	ApiKey      string
}

func NewEmailManager

func NewEmailManager(senderEmail, senderName, apiKey string) *EmailManager

func (*EmailManager) SendAccountVerificationEmail

func (eu *EmailManager) SendAccountVerificationEmail(email, firstname, otp string) error

func (*EmailManager) SendResetPasswordEmail

func (eu *EmailManager) SendResetPasswordEmail(email, firstname, otp string) error

type MediaCloudManager

type MediaCloudManager struct {
	// contains filtered or unexported fields
}

func NewMediaCloudManager

func NewMediaCloudManager(api_uri, folder string) (*MediaCloudManager, error)

func (*MediaCloudManager) DeleteImageBySecureURL

func (mcm *MediaCloudManager) DeleteImageBySecureURL(ctx context.Context, secureUrl string) *mediaErrors.AppError

func (*MediaCloudManager) UploadImage

func (mcm *MediaCloudManager) UploadImage(ctx context.Context, files []*multipart.FileHeader, collection string) ([]string, *mediaErrors.AppError)

type OTP

type OTP struct {
	ID        primitive.ObjectID `json:"id" bson:"_id,omitempty"`
	Email     string             `json:"email" bson:"email"`
	URL       string             `json:"url" bson:"url"`
	Secret    string             `json:"secret" bson:"secret"`
	ExpiresAt time.Time          `json:"expires_at" bson:"expires_at"`
	CreatedAt time.Time          `json:"created_at" bson:"created_at"`
}

type OTPManager

type OTPManager struct {
	Issuer                          string
	SignUpOtpValidityInSecs         uint
	ForgotPasswordOtpValidityInSecs uint
	// contains filtered or unexported fields
}

func NewOTPManager

func NewOTPManager(collection *mongo.Collection, issuer string, signUpOtpValidityInSecs, forgotPasswordOtpvalidityInSecs uint) *OTPManager

func (*OTPManager) DeleteOTP

func (ou *OTPManager) DeleteOTP(email string) error

func (*OTPManager) GenerateForgotPasswordOTP

func (ou *OTPManager) GenerateForgotPasswordOTP(email string) (string, error)

func (*OTPManager) GenerateSignUpOTP

func (ou *OTPManager) GenerateSignUpOTP(email string) (string, error)

func (*OTPManager) VerifyForgotPasswordOTP

func (ou *OTPManager) VerifyForgotPasswordOTP(email, otpStr string) (bool, error)

func (*OTPManager) VerifySignUpOTP

func (ou *OTPManager) VerifySignUpOTP(email, otpStr string) (bool, error)

type RefreshDetails

type RefreshDetails struct {
	RefreshUuid string
	UserId      primitive.ObjectID
}

type TokenDetails

type TokenDetails struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	AccessUuid   string `json:"-"`
	RefreshUuid  string `json:"-"`
	AtExpires    int64  `json:"at_expires"`
	RtExpires    int64  `json:"rt_expires"`
}

type TokenManager

type TokenManager struct {
	// contains filtered or unexported fields
}

func NewTokenManager

func NewTokenManager(accessTokensecretKey, refreshTokensecretKey string, accessTokenValidityInMins int64, refreshTokenValidityInHours int64, redisClient *redis.Client) *TokenManager

func (*TokenManager) DeleteToken

func (tu *TokenManager) DeleteToken(uuid string) error

func (*TokenManager) FindToken

func (tu *TokenManager) FindToken(uuid string) (string, error)

func (*TokenManager) GenerateToken

func (tu *TokenManager) GenerateToken(userId primitive.ObjectID) (*TokenDetails, error)

func (*TokenManager) IdentifyUser

func (tu *TokenManager) IdentifyUser(refreshToken string) (*RefreshDetails, error)

func (*TokenManager) SaveToken

func (tu *TokenManager) SaveToken(userId primitive.ObjectID, td *TokenDetails) error

Jump to

Keyboard shortcuts

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