Skip to content

Commit

Permalink
wingback customer data filled in correctly (#4933)
Browse files Browse the repository at this point in the history
Co-authored-by: Valentin Yanakiev <valentin.yanakiev@gmail.com>
  • Loading branch information
hero101 and valentinyanakiev authored Feb 13, 2025
1 parent d5f5d9d commit 323d0ea
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
8 changes: 6 additions & 2 deletions src/domain/space/account/account.service.license.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ export class AccountLicenseService {
}

const { user, organization } = accountDetails;
const name = user?.name ?? organization?.name;
const mainEmail = user?.email ?? organization?.email;
const name =
user?.name ?? (organization?.legalName || organization?.displayName);
const mainEmail =
user?.email ??
(organization?.email ||
`dummy-${organization?.nameID}@${organization?.nameID}.com`);

const { id: wingbackCustomerID } =
await this.licensingWingbackSubscriptionService.createCustomer({
Expand Down
21 changes: 13 additions & 8 deletions src/domain/space/account/account.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,15 @@ export class AccountService {
const [account] = await this.accountRepository.query(
`
SELECT
a.id as accountId, a.externalSubscriptionID as externalSubscriptionID,
o.id as orgId, o.contactEmail as orgContactEmail, o.legalEntityName as orgName,
u.id as userId, u.email as userEmail, CONCAT(u.firstName, ' ', u.lastName) as userName
FROM account as a
LEFT JOIN user as u on a.id = u.accountID
LEFT JOIN organization as o on a.id = o.accountID
WHERE a.id = ?
account.id as accountId, account.externalSubscriptionID as externalSubscriptionID,
organization.id as orgId, organization.contactEmail as orgContactEmail, organization.legalEntityName as orgLegalName, organization.nameID as orgNameID,
profile.displayName as orgDisplayName,
user.id as userId, user.email as userEmail, CONCAT(user.firstName, ' ', user.lastName) as userName
FROM account
LEFT JOIN user on account.id = user.accountID
LEFT JOIN organization on account.id = organization.accountID
left join profile on organization.profileId = profile.id
WHERE account.id = ?
`,
[accountID]
);
Expand All @@ -255,7 +257,10 @@ export class AccountService {
? {
id: account.orgId,
email: account.orgContactEmail,
name: account.orgName,
legalName: account.orgLegalName,
orgLegalName: account.orgLegalName,
displayName: account.orgDisplayName,
nameID: account.orgNameID,
}
: undefined,
};
Expand Down

0 comments on commit 323d0ea

Please sign in to comment.