Documentation ¶
Index ¶
- func CensorEmail(email string) string
- func CheckPassword(password string, hash string) bool
- func ExtractHashtags(text string) []string
- func FormatImageUrl(imageId string, extension string) string
- func GenerateAccessToken(username string) (string, error)
- func GenerateImageMetadataDTOFromImage(image *models.Image) *models.ImageMetadataDTO
- func GenerateLocationDTOFromLocation(location *models.Location) *models.LocationDTO
- func GenerateRefreshToken(username string) (string, error)
- func GenerateSixDigitCode() (int64, error)
- func GenerateUserDTOFromUser(user *models.User) *models.UserDTO
- func GetActivationEmailBody(token string) string
- func GetPasswordResetEmailBody(username string, resetToken string) string
- func GetWelcomeEmailBody(username string) string
- func HashPassword(password string) (string, error)
- func VerifyJWTToken(tokenString string) (string, bool, error)
- type MockValidator
- type Validator
- func (v *Validator) ValidateEmailExistance(email string) bool
- func (v *Validator) ValidateEmailSyntax(email string) bool
- func (v *Validator) ValidateImage(imageData []byte) (bool, string, int, int)
- func (v *Validator) ValidateLatitude(latitude float64) bool
- func (v *Validator) ValidateLongitude(longitude float64) bool
- func (v *Validator) ValidateNickname(nickname string) bool
- func (v *Validator) ValidatePassword(password string) bool
- func (v *Validator) ValidateStatus(status string) bool
- func (v *Validator) ValidateUsername(username string) bool
- type ValidatorInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CensorEmail ¶
CensorEmail censors the email address for the response converts testmail@gmail.com to tes*****@gmail.com
func CheckPassword ¶
CheckPassword checks if a given password matches with the given hash (contains salt)
func ExtractHashtags ¶
ExtractHashtags extracts all hashtags from a given text and returns them as a slice of strings
func FormatImageUrl ¶
FormatImageUrl formats the image url for the response adds the base url with image id and file extension
func GenerateAccessToken ¶
GenerateAccessToken generates new access jwt token with user id claim for 3 hours validity
func GenerateImageMetadataDTOFromImage ¶
func GenerateImageMetadataDTOFromImage(image *models.Image) *models.ImageMetadataDTO
GenerateImageMetadataDTOFromImage generates an ImageMetadataDTO from an Image and returns nil if the Image is nil
func GenerateLocationDTOFromLocation ¶
func GenerateLocationDTOFromLocation(location *models.Location) *models.LocationDTO
GenerateLocationDTOFromLocation generates a LocationDTO from a Location and returns nil if the Location is nil
func GenerateRefreshToken ¶
GenerateRefreshToken generates new refresh jwt token with user id claim for one week validity
func GenerateSixDigitCode ¶
GenerateSixDigitCode generates a code that is used for email verification
func GenerateUserDTOFromUser ¶
GenerateUserDTOFromUser generates a UserDTO from a User and returns nil if the User is nil This function is used multiple times in the services to easily convert a User to a DTO with correct image wrapping
func GetActivationEmailBody ¶
GetActivationEmailBody returns the HTML body for an activation email sending the activation code
func GetPasswordResetEmailBody ¶
GetPasswordResetEmailBody returns the HTML body for a password reset email
func GetWelcomeEmailBody ¶
GetWelcomeEmailBody returns the HTML body for a welcome email
func HashPassword ¶
HashPassword hashes a given password with a random salt and returns hash
Types ¶
type MockValidator ¶
func (*MockValidator) ValidateEmailExistance ¶
func (m *MockValidator) ValidateEmailExistance(email string) bool
ValidateEmailExistance Only override ValidateEmailExistance function because it is the only function that needs to be mocked
type Validator ¶
type Validator struct { }
func NewValidator ¶
func NewValidator() *Validator
func (*Validator) ValidateEmailExistance ¶
ValidateEmailExistance tries to reach out to email to see if it really exists
func (*Validator) ValidateEmailSyntax ¶
ValidateEmailSyntax validates if an email meets specifications
func (*Validator) ValidateImage ¶
ValidateImage validates if an image is correct file type and can be "opened", additionally returns file format, width and height
func (*Validator) ValidateLatitude ¶
ValidateLatitude validates if latitude is in valid range
func (*Validator) ValidateLongitude ¶
ValidateLongitude validates if longitude is in valid range
func (*Validator) ValidateNickname ¶
ValidateNickname validates if a nickname meets specifications
func (*Validator) ValidatePassword ¶
ValidatePassword validates if a password meets specifications
func (*Validator) ValidateStatus ¶
ValidateStatus validates if a status meets specifications
func (*Validator) ValidateUsername ¶
ValidateUsername validates if a password meets specifications
type ValidatorInterface ¶
type ValidatorInterface interface { ValidateUsername(username string) bool ValidateNickname(nickname string) bool ValidateEmailSyntax(email string) bool ValidateEmailExistance(email string) bool ValidatePassword(password string) bool ValidateStatus(status string) bool ValidateLatitude(latitude float64) bool ValidateLongitude(longitude float64) bool ValidateImage(imageData []byte) (bool, string, int, int) }