diff --git a/app/router/router.tsx b/app/router/router.tsx index dcf16269134..dac1b18e927 100644 --- a/app/router/router.tsx +++ b/app/router/router.tsx @@ -368,12 +368,14 @@ class Router { // Require the user to create an org if they are logged in but not part of // an org. if (user && !user.groups?.length) { - if (capabilities.config.customerSubdomain) { - const params = new URLSearchParams({ source_url: window.location.href }); - return Path.orgAccessDeniedPath + "?" + params.toString(); - } else { - return Path.createOrgPath; - } + return Path.createOrgPath; + } + + // No selected group on subdomain means either the group doesn't exist or + // the user does not have access to it. + if (user && !user.selectedGroup.id && capabilities.config.customerSubdomain) { + const params = new URLSearchParams({ source_url: window.location.href }); + return Path.orgAccessDeniedPath + "?" + params.toString(); } const path = window.location.pathname; diff --git a/server/buildbuddy_server/buildbuddy_server.go b/server/buildbuddy_server/buildbuddy_server.go index 0166b267315..bc03ec7eade 100644 --- a/server/buildbuddy_server/buildbuddy_server.go +++ b/server/buildbuddy_server/buildbuddy_server.go @@ -826,6 +826,7 @@ func selectedGroup(ctx context.Context, preferredGroupID string, groupRoles []*t return gr } } + return nil } if preferredGroupID != "" { for _, gr := range groupRoles {