From 604e2757c84f59abc99324f10c564a6b965fcba1 Mon Sep 17 00:00:00 2001 From: caoshengdong Date: Fri, 3 Jun 2022 00:37:22 +0800 Subject: [PATCH] fix: fix the problem that user owner is not updated when updating organization name (#775) * fix: use openid or unionid as username rather than nickname when logging with WeChat FIX #762 * fix: fix the problem that user owner is not updated when updating organization name * Update wechat.go Co-authored-by: Gucheng <85475922+nomeguy@users.noreply.github.com> --- object/organization.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/object/organization.go b/object/organization.go index f8c2ca6c5..e5ec48d9c 100644 --- a/object/organization.go +++ b/object/organization.go @@ -121,11 +121,15 @@ func UpdateOrganization(id string, organization *Organization) bool { } if name != organization.Name { - applications := GetApplicationsByOrganizationName("admin", name) - for _, application := range applications { + go func() { + application := new(Application) application.Organization = organization.Name - UpdateApplication(application.GetId(), application) - } + _, _ = adapter.Engine.Where("organization=?", name).Update(application) + + user := new(User) + user.Owner = organization.Name + _, _ = adapter.Engine.Where("owner=?", name).Update(user) + }() } if organization.MasterPassword != "" && organization.MasterPassword != "***" {