Compare commits
No commits in common. "4ca78df050c501c2e93b22884d3cd9513a1c4103" and "5a9f4a594082789384723d4f6175dfbafe810844" have entirely different histories.
4ca78df050
...
5a9f4a5940
|
@ -202,10 +202,10 @@ 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, nil)
|
return NewAccountError(ErrKeyEmailVerificationFailed, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
return NewAccountError(ErrKeySecurityInvalidToken, nil)
|
return NewAccountError(ErrKeyDatabaseOperationFailed, result.Error)
|
||||||
}
|
}
|
||||||
|
|
||||||
if verification.ExpiresAt.Before(time.Now()) {
|
if verification.ExpiresAt.Before(time.Now()) {
|
||||||
|
|
|
@ -27,6 +27,7 @@ const (
|
||||||
// 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"
|
||||||
|
@ -75,6 +76,7 @@ var defaultErrorMessages = map[string]string{
|
||||||
// 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.",
|
||||||
|
@ -122,6 +124,7 @@ var (
|
||||||
// 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,
|
||||||
|
|
|
@ -172,7 +172,7 @@ func (a AccountAPI) verifyEmail(jc jape.Context) {
|
||||||
|
|
||||||
err := a.accounts.VerifyEmail(request.Email, request.Token)
|
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
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue