fix: impersonation detecting orgs correctly. (#13889)

* feat:fix correctly detect impersonation organization

* chore: remove logs

* Update packages/features/ee/impersonation/lib/ImpersonationProvider.ts

---------

Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
This commit is contained in:
sean-brydon
2024-02-28 12:16:46 +00:00
committed by GitHub
co-authored by Udit Takkar
parent 1463f97f14
commit 5ba0ee8e85
@@ -198,6 +198,7 @@ async function isReturningToSelf({ session, creds }: { session: Session | null;
role: true,
organizationId: true,
locale: true,
profiles: true,
teams: {
where: {
accepted: true, // Ensure they are apart of the team and not just invited.
@@ -213,7 +214,10 @@ async function isReturningToSelf({ session, creds }: { session: Session | null;
if (returningUser) {
// Skip for none org users
if (returningUser.role !== "ADMIN" && !returningUser.organizationId) return;
const inOrg =
returningUser.organizationId || // Keep for backwards compatability
returningUser.profiles.some((profile) => profile.organizationId !== undefined); // New way of seeing if the user has a profile in orgs.
if (returningUser.role !== "ADMIN" && !inOrg) return;
const hasTeams = returningUser.teams.length >= 1;