Users: clean up OrgId when all user orgs are removed (#46003)

* Clean up orgId when user organization is removed

* Add a test for removing user org

* Fix linting errors

* Update comment

* Fix linting errors

* Make removing user org more explicit
This commit is contained in:
Piotr Jamróz
2022-04-06 08:35:58 +02:00
committed by GitHub
parent f9d86557cf
commit 8490fd77e3
4 changed files with 64 additions and 1 deletions
+6
View File
@@ -307,6 +307,12 @@ func (ss *SQLStore) RemoveOrgUser(ctx context.Context, cmd *models.RemoveOrgUser
}
cmd.UserWasDeleted = true
} else {
// no orgs, but keep the user -> clean up orgId
err = removeUserOrg(sess, user.Id)
if err != nil {
return err
}
}
return nil