diff --git a/packages/server/src/common/config/cloud.ts b/packages/server/src/common/config/cloud.ts new file mode 100644 index 000000000..1b883b04e --- /dev/null +++ b/packages/server/src/common/config/cloud.ts @@ -0,0 +1,5 @@ +import { registerAs } from '@nestjs/config'; + +export default registerAs('cloud', () => ({ + hostedOnCloud: process.env.HOSTED_ON_BIGCAPITAL_CLOUD === 'true', +})); diff --git a/packages/server/src/common/config/index.ts b/packages/server/src/common/config/index.ts index ca88bf945..607858638 100644 --- a/packages/server/src/common/config/index.ts +++ b/packages/server/src/common/config/index.ts @@ -15,9 +15,11 @@ import mail from './mail'; import loops from './loops'; import bankfeed from './bankfeed'; import throttle from './throttle'; +import cloud from './cloud'; export const config = [ systemDatabase, + cloud, tenantDatabase, signup, gotenberg, diff --git a/packages/server/src/modules/Auth/commands/AuthSignup.service.ts b/packages/server/src/modules/Auth/commands/AuthSignup.service.ts index 9eb595e92..90188c77d 100644 --- a/packages/server/src/modules/Auth/commands/AuthSignup.service.ts +++ b/packages/server/src/modules/Auth/commands/AuthSignup.service.ts @@ -16,6 +16,7 @@ import { import { defaultTo } from 'ramda'; import { ERRORS } from '../Auth.constants'; import { hashPassword } from '../Auth.utils'; +import { ClsService } from 'nestjs-cls'; @Injectable() export class AuthSignupService { @@ -29,6 +30,7 @@ export class AuthSignupService { private readonly configService: ConfigService, private readonly eventEmitter: EventEmitter2, private readonly tenantsManager: TenantsManagerService, + private readonly clsService: ClsService, @Inject(SystemUser.name) private readonly systemUserModel: typeof SystemUser, @@ -70,6 +72,11 @@ export class AuthSignupService { tenantId: tenant.id, inviteAcceptedAt, }); + // Set the user in the cls service. + this.clsService.set('tenantId', user.tenantId); + this.clsService.set('userId', user.id); + this.clsService.set('organizationId', tenant.organizationId); + // Triggers signed up event. await this.eventEmitter.emitAsync(events.auth.signUp, { signupDTO, diff --git a/packages/server/src/modules/Subscription/commands/NewSubscription.service.ts b/packages/server/src/modules/Subscription/commands/NewSubscription.service.ts index f5f84f279..d8dbaaf82 100644 --- a/packages/server/src/modules/Subscription/commands/NewSubscription.service.ts +++ b/packages/server/src/modules/Subscription/commands/NewSubscription.service.ts @@ -15,7 +15,7 @@ export class NewSubscriptionService { @Inject(Plan.name) private readonly planModel: typeof Plan, - ) {} + ) { } /** * Give the tenant a new subscription. diff --git a/packages/server/src/modules/Subscription/subscribers/SubscribeFreeOnSignupCommunity.ts b/packages/server/src/modules/Subscription/subscribers/SubscribeFreeOnSignupCommunity.ts index 0faddde21..202e1207d 100644 --- a/packages/server/src/modules/Subscription/subscribers/SubscribeFreeOnSignupCommunity.ts +++ b/packages/server/src/modules/Subscription/subscribers/SubscribeFreeOnSignupCommunity.ts @@ -9,7 +9,7 @@ export class SubscribeFreeOnSignupCommunity { constructor( private readonly subscriptionApp: SubscriptionApplication, private readonly configService: ConfigService, - ) {} + ) { } /** * Creates a new free subscription once the user signup if the app is self-hosted. @@ -18,8 +18,8 @@ export class SubscribeFreeOnSignupCommunity { */ @OnEvent(events.auth.signUp) async subscribeFreeOnSigupCommunity({ signupDTO, tenant, user }) { - if (this.configService.get('hostedOnBigcapitalCloud')) return null; + if (this.configService.get('cloud.hostedOnCloud')) return null; - // await this.subscriptionApp.createNewSubscription('free'); + await this.subscriptionApp.createNewSubscription('free'); } } diff --git a/packages/webapp/src/components/PageForm/FormTopbar.tsx b/packages/webapp/src/components/PageForm/FormTopbar.tsx index f1cac1155..15184f599 100644 --- a/packages/webapp/src/components/PageForm/FormTopbar.tsx +++ b/packages/webapp/src/components/PageForm/FormTopbar.tsx @@ -15,10 +15,12 @@ export function FormTopbar({ className, children }) { const FormTopBarRoot = styled(Navbar)` --color-form-topbar-background: #fff; --color-form-topbar-border: #c7d5db; + --color-divider-color: #d2dce2; .bp4-dark & { --color-form-topbar-background: var(--color-dark-gray1); --color-form-topbar-border: rgba(255, 255, 255, 0.15); + --color-divider-color: rgba(255, 255, 255, 0.25); } height: 35px; padding: 0 20px; @@ -34,7 +36,7 @@ const FormTopBarRoot = styled(Navbar)` height: 35px; } .bp4-navbar-divider { - border-left-color: #d2dce2; + border-left-color: var(--color-divider-color); } .bp4-skeleton { max-height: 10px;