fix: if user is already verified, abort
This commit is contained in:
parent
12a9ad28fd
commit
64eea68a84
|
@ -134,6 +134,10 @@ func (s AccountServiceDefault) SendEmailVerification(userId uint) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if user.Verified {
|
||||||
|
return NewAccountError(ErrKeyAccountAlreadyVerified, nil)
|
||||||
|
}
|
||||||
|
|
||||||
token := GenerateSecurityToken()
|
token := GenerateSecurityToken()
|
||||||
|
|
||||||
var verification models.EmailVerification
|
var verification models.EmailVerification
|
||||||
|
|
|
@ -25,7 +25,8 @@ const (
|
||||||
ErrKeyHashingFailed = "ErrHashingFailed"
|
ErrKeyHashingFailed = "ErrHashingFailed"
|
||||||
|
|
||||||
// Account update errors
|
// Account update errors
|
||||||
ErrKeyAccountUpdateFailed = "ErrAccountUpdateFailed"
|
ErrKeyAccountUpdateFailed = "ErrAccountUpdateFailed"
|
||||||
|
ErrKeyAccountAlreadyVerified = "ErrAccountAlreadyVerified"
|
||||||
|
|
||||||
// JWT generation errors
|
// JWT generation errors
|
||||||
ErrKeyJWTGenerationFailed = "ErrJWTGenerationFailed"
|
ErrKeyJWTGenerationFailed = "ErrJWTGenerationFailed"
|
||||||
|
@ -72,7 +73,8 @@ 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.",
|
||||||
|
|
||||||
// JWT generation errors
|
// JWT generation errors
|
||||||
ErrKeyJWTGenerationFailed: "Failed to generate a new JWT token.",
|
ErrKeyJWTGenerationFailed: "Failed to generate a new JWT token.",
|
||||||
|
@ -118,7 +120,8 @@ var (
|
||||||
ErrKeyLoginFailed: http.StatusInternalServerError,
|
ErrKeyLoginFailed: http.StatusInternalServerError,
|
||||||
|
|
||||||
// Account update errors
|
// Account update errors
|
||||||
ErrKeyAccountUpdateFailed: http.StatusInternalServerError,
|
ErrKeyAccountUpdateFailed: http.StatusInternalServerError,
|
||||||
|
ErrKeyAccountAlreadyVerified: http.StatusConflict,
|
||||||
|
|
||||||
// JWT generation errors
|
// JWT generation errors
|
||||||
ErrKeyJWTGenerationFailed: http.StatusInternalServerError,
|
ErrKeyJWTGenerationFailed: http.StatusInternalServerError,
|
||||||
|
|
Loading…
Reference in New Issue