fix: check to ensure error is something other than ErrRecordNotFound, or that exists is true

This commit is contained in:
Derrick Hammer 2024-03-19 09:29:29 -04:00
parent 9e52d35d2f
commit 9ea77fb5c3
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 1 additions and 5 deletions

View File

@ -280,11 +280,7 @@ func (s AccountServiceDefault) UpdateAccountName(userId uint, firstName string,
func (s AccountServiceDefault) UpdateAccountEmail(userId uint, email string, password string) error { func (s AccountServiceDefault) UpdateAccountEmail(userId uint, email string, password string) error {
exists, _, err := s.EmailExists(email) exists, _, err := s.EmailExists(email)
if err != nil { if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) || exists {
return err
}
if exists {
return NewAccountError(ErrKeyEmailAlreadyExists, nil) return NewAccountError(ErrKeyEmailAlreadyExists, nil)
} }