From 682cfc22bfaf636b88acb375447ce4fea8058818 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 24 Feb 2022 23:31:00 +0800 Subject: [PATCH 1/2] Fix update user --- models/user/user.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/models/user/user.go b/models/user/user.go index d0f1d9d747779..9ee1f41442664 100644 --- a/models/user/user.go +++ b/models/user/user.go @@ -868,13 +868,14 @@ func updateUser(ctx context.Context, u *User, changePrimaryEmail bool, cols ...s } if !primaryEmailExist { - _, err = e.Insert(&EmailAddress{ + if _, err = e.Insert(&EmailAddress{ Email: u.Email, UID: u.ID, IsActivated: true, IsPrimary: true, - }) - return err + }); err != nil { + return err + } } } From 580da523e518b72628ea1fa1474e548362381650 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 24 Feb 2022 19:00:56 +0100 Subject: [PATCH 2/2] nit --- models/user/user.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/user/user.go b/models/user/user.go index 9ee1f41442664..e581067bbd5ac 100644 --- a/models/user/user.go +++ b/models/user/user.go @@ -868,7 +868,7 @@ func updateUser(ctx context.Context, u *User, changePrimaryEmail bool, cols ...s } if !primaryEmailExist { - if _, err = e.Insert(&EmailAddress{ + if _, err := e.Insert(&EmailAddress{ Email: u.Email, UID: u.ID, IsActivated: true,