@@ -3,6 +3,7 @@ import CredentialsProvider from "next-auth/providers/credentials";
33import { z } from "zod" ;
44
55import { ensureOrganizationIsReviewed } from "@calcom/ee/organizations/lib/ensureOrganizationIsReviewed" ;
6+ import { getOrgFullOrigin , subdomainSuffix } from "@calcom/ee/organizations/lib/orgDomains" ;
67import { getSession } from "@calcom/features/auth/lib/getSession" ;
78import { getSpecificPermissions } from "@calcom/features/pbac/lib/resource-permissions" ;
89import { ProfileRepository } from "@calcom/lib/server/repository/profile" ;
@@ -53,6 +54,8 @@ const auditAndReturnNextUser = async (
5354 } ,
5455 } ) ;
5556
57+ const profileOrg = impersonatedUser . profile ?. organization ;
58+
5659 const obj = {
5760 id : impersonatedUser . id ,
5861 username : impersonatedUser . username ,
@@ -63,6 +66,18 @@ const auditAndReturnNextUser = async (
6366 organizationId : impersonatedUser . organizationId ,
6467 locale : impersonatedUser . locale ,
6568 profile : impersonatedUser . profile ,
69+ // Add org object if the user belongs to an organization
70+ ...( profileOrg && {
71+ org : {
72+ id : profileOrg . id ,
73+ name : profileOrg . name ,
74+ slug : profileOrg . slug || "" ,
75+ logoUrl : profileOrg . logoUrl ,
76+ fullDomain : getOrgFullOrigin ( profileOrg . slug || "" ) ,
77+ domainSuffix : subdomainSuffix ( ) ,
78+ role : profileOrg . members ?. [ 0 ] ?. role || MembershipRole . MEMBER ,
79+ } ,
80+ } ) ,
6681 } ;
6782
6883 if ( ! isReturningToSelf ) {
0 commit comments