Documentation
¶
Index ¶
- func ComparePassword(hashedPassword string, plainPassword string) error
- func ExtractUserIDFromToken(token *jwt.Token) (uuid.UUID, error)
- func GenerateAccessToken(userID uuid.UUID) (string, error)
- func GenerateActivationToken(userID uuid.UUID) (string, error)
- func GeneratePasswordResetToken(userID uuid.UUID) (string, error)
- func GenerateRefreshToken(userID uuid.UUID) (string, error)
- func GetEnv(env, defaultValue string) string
- func GetEnvAsInt(env string, defaultValue int) int
- func HashPassword(password string) (string, error)
- func NewLogger() *logrus.Logger
- func VerifyAccessToken(tokenString string) (*jwt.Token, error)
- func VerifyActivationToken(tokenString string) (*jwt.Token, error)
- func VerifyPasswordResetToken(tokenString string) (*jwt.Token, error)
- func VerifyRefreshToken(tokenString string) (*jwt.Token, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComparePassword ¶
ComparePassword compares the hashed password with the plain password.
Parameters:
- hashedPassword (string): The hashed password to compare.
- plainPassword (string): The plain password to compare.
Returns:
- error: An error if passwords do not match. Returns nil if passwords match.
func ExtractUserIDFromToken ¶
ExtractUserIDFromToken extracts user ID from a valid JWT token.
Parameters:
- token *jwt.Token: Valid JWT token.
Returns:
- uuid.UUID: User ID extracted from the token.
- error: An error if user ID extraction fails.
func GenerateAccessToken ¶
GenerateAccessToken generates a new JWT access token.
Parameters:
- userID (uuid.UUID): User ID for whom to generate the token.
Returns:
- string: JWT access token.
- error: An error if token generation fails.
func GenerateActivationToken ¶
GenerateActivationToken generates a new JWT activation token.
func GeneratePasswordResetToken ¶
GeneratePasswordResetToken generates a new JWT password reset token.
func GenerateRefreshToken ¶
GenerateRefreshToken generates a new JWT refresh token.
Parameters:
- userID (uuid.UUID): User ID for whom to generate the token.
Returns:
- string: JWT refresh token.
- error: An error if token generation fails.
func GetEnv ¶
GetEnv returns the value of an environment variable or a default value if the environment variable is not set. The value is trimmed of leading and trailing whitespace.
Parameters:
- env (string): The name of the environment variable.
- defaultValue (string): The default value to return if the environment variable is not set.
Returns:
- environment (string): The value of the environment variable or the default value.
func GetEnvAsInt ¶
GetEnvAsInt returns the value of an environment variable as an integer or a default value if the environment variable is not set or is not a valid integer. The value is trimmed of leading and trailing whitespace.
Parameters:
- env (string): The name of the environment variable.
- defaultValue (int): The default value to return if the environment variable is not set or is not a valid integer.
Returns:
- value (int): The value of the environment variable as an integer or the default value.
func HashPassword ¶
HashPassword hashes the password using bcrypt.
Parameters:
- password (string): The password to be hashed.
Returns:
- string: The hashed password.
- error: An error if hashing fails.
func NewLogger ¶
NewLogger creates a new logger and returns it.
Returns:
- logger (*logrus.Logger): The logger instance.
func VerifyAccessToken ¶
VerifyAccessToken verifies the JWT access token.
Parameters:
- tokenString (string): JWT access token string.
Returns:
- *jwt.Token: Parsed JWT token if valid.
- error: An error if token verification fails.
func VerifyActivationToken ¶
VerifyActivationToken verifies the JWT activation token.
func VerifyPasswordResetToken ¶
VerifyPasswordResetToken verifies the JWT password reset token.
func VerifyRefreshToken ¶
VerifyRefreshToken verifies the JWT refresh token.
Parameters:
- tokenString (string): JWT refresh token string.
Returns:
- *jwt.Token: Parsed JWT token if valid.
- error: An error if token verification fails.
Types ¶
This section is empty.