fix: add error for email verification

This commit is contained in:
Derrick Hammer 2024-03-26 20:19:38 -04:00
parent 64eea68a84
commit ea5a97c613
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 10 additions and 7 deletions

View File

@ -202,7 +202,7 @@ func (s AccountServiceDefault) VerifyEmail(email string, token string) error {
if result.Error != nil { if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) { if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return NewAccountError(ErrKeyUserNotFound, result.Error) return NewAccountError(ErrKeyEmailVerificationFailed, result.Error)
} }
return NewAccountError(ErrKeyDatabaseOperationFailed, result.Error) return NewAccountError(ErrKeyDatabaseOperationFailed, result.Error)

View File

@ -25,8 +25,9 @@ const (
ErrKeyHashingFailed = "ErrHashingFailed" ErrKeyHashingFailed = "ErrHashingFailed"
// Account update errors // Account update errors
ErrKeyAccountUpdateFailed = "ErrAccountUpdateFailed" ErrKeyAccountUpdateFailed = "ErrAccountUpdateFailed"
ErrKeyAccountAlreadyVerified = "ErrAccountAlreadyVerified" ErrKeyAccountAlreadyVerified = "ErrAccountAlreadyVerified"
ErrKeyEmailVerificationFailed = "ErrEmailVerificationFailed"
// JWT generation errors // JWT generation errors
ErrKeyJWTGenerationFailed = "ErrJWTGenerationFailed" ErrKeyJWTGenerationFailed = "ErrJWTGenerationFailed"
@ -73,8 +74,9 @@ var defaultErrorMessages = map[string]string{
ErrKeyLoginFailed: "Login failed due to an internal error.", ErrKeyLoginFailed: "Login failed due to an internal error.",
// Account update errors // Account update errors
ErrKeyAccountUpdateFailed: "Failed to update account information.", ErrKeyAccountUpdateFailed: "Failed to update account information.",
ErrKeyAccountAlreadyVerified: "Account is already verified.", ErrKeyAccountAlreadyVerified: "Account is already verified.",
ErrKeyEmailVerificationFailed: "Failed to verify email address.",
// JWT generation errors // JWT generation errors
ErrKeyJWTGenerationFailed: "Failed to generate a new JWT token.", ErrKeyJWTGenerationFailed: "Failed to generate a new JWT token.",
@ -120,8 +122,9 @@ var (
ErrKeyLoginFailed: http.StatusInternalServerError, ErrKeyLoginFailed: http.StatusInternalServerError,
// Account update errors // Account update errors
ErrKeyAccountUpdateFailed: http.StatusInternalServerError, ErrKeyAccountUpdateFailed: http.StatusInternalServerError,
ErrKeyAccountAlreadyVerified: http.StatusConflict, ErrKeyAccountAlreadyVerified: http.StatusConflict,
ErrKeyEmailVerificationFailed: http.StatusInternalServerError,
// JWT generation errors // JWT generation errors
ErrKeyJWTGenerationFailed: http.StatusInternalServerError, ErrKeyJWTGenerationFailed: http.StatusInternalServerError,