From 3473551f6c774c2fbc22cbb2d3633807df6bf668 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Tue, 19 Mar 2024 09:48:45 -0400 Subject: [PATCH] fix: ensure exists check only matches if it is a different account id --- account/account.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/account/account.go b/account/account.go index cb8c7a0..5b70f78 100644 --- a/account/account.go +++ b/account/account.go @@ -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) }