fix: ensure exists check only matches if it is a different account id

This commit is contained in:
Derrick Hammer 2024-03-19 09:48:45 -04:00
parent 080bef354d
commit 3473551f6c
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 2 additions and 2 deletions

View File

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