fix: cloud subscription flag

This commit is contained in:
Ahmed Bouhuolia
2025-11-30 22:38:00 +02:00
parent e196d485cf
commit 3648fb3ffc
6 changed files with 21 additions and 5 deletions

View File

@@ -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,

View File

@@ -15,7 +15,7 @@ export class NewSubscriptionService {
@Inject(Plan.name)
private readonly planModel: typeof Plan,
) {}
) { }
/**
* Give the tenant a new subscription.

View File

@@ -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');
}
}