Compare commits
3 Commits
5a9f4a5940
...
4ca78df050
Author | SHA1 | Date |
---|---|---|
Derrick Hammer | 4ca78df050 | |
Derrick Hammer | adc5bc213e | |
Derrick Hammer | 501de26793 |
|
@ -202,10 +202,10 @@ func (s AccountServiceDefault) VerifyEmail(email string, token string) error {
|
|||
|
||||
if result.Error != nil {
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
return NewAccountError(ErrKeyEmailVerificationFailed, nil)
|
||||
return NewAccountError(ErrKeyUserNotFound, nil)
|
||||
}
|
||||
|
||||
return NewAccountError(ErrKeyDatabaseOperationFailed, result.Error)
|
||||
return NewAccountError(ErrKeySecurityInvalidToken, nil)
|
||||
}
|
||||
|
||||
if verification.ExpiresAt.Before(time.Now()) {
|
||||
|
|
|
@ -25,9 +25,8 @@ const (
|
|||
ErrKeyHashingFailed = "ErrHashingFailed"
|
||||
|
||||
// Account update errors
|
||||
ErrKeyAccountUpdateFailed = "ErrAccountUpdateFailed"
|
||||
ErrKeyAccountAlreadyVerified = "ErrAccountAlreadyVerified"
|
||||
ErrKeyEmailVerificationFailed = "ErrEmailVerificationFailed"
|
||||
ErrKeyAccountUpdateFailed = "ErrAccountUpdateFailed"
|
||||
ErrKeyAccountAlreadyVerified = "ErrAccountAlreadyVerified"
|
||||
|
||||
// JWT generation errors
|
||||
ErrKeyJWTGenerationFailed = "ErrJWTGenerationFailed"
|
||||
|
@ -74,9 +73,8 @@ var defaultErrorMessages = map[string]string{
|
|||
ErrKeyLoginFailed: "Login failed due to an internal error.",
|
||||
|
||||
// Account update errors
|
||||
ErrKeyAccountUpdateFailed: "Failed to update account information.",
|
||||
ErrKeyAccountAlreadyVerified: "Account is already verified.",
|
||||
ErrKeyEmailVerificationFailed: "Failed to verify email address.",
|
||||
ErrKeyAccountUpdateFailed: "Failed to update account information.",
|
||||
ErrKeyAccountAlreadyVerified: "Account is already verified.",
|
||||
|
||||
// JWT generation errors
|
||||
ErrKeyJWTGenerationFailed: "Failed to generate a new JWT token.",
|
||||
|
@ -122,9 +120,8 @@ var (
|
|||
ErrKeyLoginFailed: http.StatusInternalServerError,
|
||||
|
||||
// Account update errors
|
||||
ErrKeyAccountUpdateFailed: http.StatusInternalServerError,
|
||||
ErrKeyAccountAlreadyVerified: http.StatusConflict,
|
||||
ErrKeyEmailVerificationFailed: http.StatusInternalServerError,
|
||||
ErrKeyAccountUpdateFailed: http.StatusInternalServerError,
|
||||
ErrKeyAccountAlreadyVerified: http.StatusConflict,
|
||||
|
||||
// JWT generation errors
|
||||
ErrKeyJWTGenerationFailed: http.StatusInternalServerError,
|
||||
|
|
|
@ -172,7 +172,7 @@ func (a AccountAPI) verifyEmail(jc jape.Context) {
|
|||
|
||||
err := a.accounts.VerifyEmail(request.Email, request.Token)
|
||||
|
||||
if jc.Check("failed to verify email", err) != nil {
|
||||
if jc.Check("Failed to verify email", err) != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue