Compare commits
2 Commits
12a9ad28fd
...
ea5a97c613
Author | SHA1 | Date |
---|---|---|
Derrick Hammer | ea5a97c613 | |
Derrick Hammer | 64eea68a84 |
|
@ -134,6 +134,10 @@ func (s AccountServiceDefault) SendEmailVerification(userId uint) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if user.Verified {
|
||||
return NewAccountError(ErrKeyAccountAlreadyVerified, nil)
|
||||
}
|
||||
|
||||
token := GenerateSecurityToken()
|
||||
|
||||
var verification models.EmailVerification
|
||||
|
@ -198,7 +202,7 @@ func (s AccountServiceDefault) VerifyEmail(email string, token string) error {
|
|||
|
||||
if result.Error != nil {
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
return NewAccountError(ErrKeyUserNotFound, result.Error)
|
||||
return NewAccountError(ErrKeyEmailVerificationFailed, result.Error)
|
||||
}
|
||||
|
||||
return NewAccountError(ErrKeyDatabaseOperationFailed, result.Error)
|
||||
|
|
|
@ -25,7 +25,9 @@ const (
|
|||
ErrKeyHashingFailed = "ErrHashingFailed"
|
||||
|
||||
// Account update errors
|
||||
ErrKeyAccountUpdateFailed = "ErrAccountUpdateFailed"
|
||||
ErrKeyAccountUpdateFailed = "ErrAccountUpdateFailed"
|
||||
ErrKeyAccountAlreadyVerified = "ErrAccountAlreadyVerified"
|
||||
ErrKeyEmailVerificationFailed = "ErrEmailVerificationFailed"
|
||||
|
||||
// JWT generation errors
|
||||
ErrKeyJWTGenerationFailed = "ErrJWTGenerationFailed"
|
||||
|
@ -72,7 +74,9 @@ var defaultErrorMessages = map[string]string{
|
|||
ErrKeyLoginFailed: "Login failed due to an internal error.",
|
||||
|
||||
// Account update errors
|
||||
ErrKeyAccountUpdateFailed: "Failed to update account information.",
|
||||
ErrKeyAccountUpdateFailed: "Failed to update account information.",
|
||||
ErrKeyAccountAlreadyVerified: "Account is already verified.",
|
||||
ErrKeyEmailVerificationFailed: "Failed to verify email address.",
|
||||
|
||||
// JWT generation errors
|
||||
ErrKeyJWTGenerationFailed: "Failed to generate a new JWT token.",
|
||||
|
@ -118,7 +122,9 @@ var (
|
|||
ErrKeyLoginFailed: http.StatusInternalServerError,
|
||||
|
||||
// Account update errors
|
||||
ErrKeyAccountUpdateFailed: http.StatusInternalServerError,
|
||||
ErrKeyAccountUpdateFailed: http.StatusInternalServerError,
|
||||
ErrKeyAccountAlreadyVerified: http.StatusConflict,
|
||||
ErrKeyEmailVerificationFailed: http.StatusInternalServerError,
|
||||
|
||||
// JWT generation errors
|
||||
ErrKeyJWTGenerationFailed: http.StatusInternalServerError,
|
||||
|
|
Loading…
Reference in New Issue