fix(core): Make enterprise trial requests via the backend (no-changelog) (#9784)
This commit is contained in:
committed by
GitHub
parent
f7d7404907
commit
876bcbb04c
@@ -1,5 +1,5 @@
|
||||
import { Get, Post, RestController, GlobalScope } from '@/decorators';
|
||||
import { LicenseRequest } from '@/requests';
|
||||
import { AuthenticatedRequest, LicenseRequest } from '@/requests';
|
||||
import { LicenseService } from './license.service';
|
||||
|
||||
@RestController('/license')
|
||||
@@ -11,6 +11,12 @@ export class LicenseController {
|
||||
return await this.licenseService.getLicenseData();
|
||||
}
|
||||
|
||||
@Post('/enterprise/request_trial')
|
||||
@GlobalScope('license:manage')
|
||||
async requestEnterpriseTrial(req: AuthenticatedRequest) {
|
||||
await this.licenseService.requestEnterpriseTrial(req.user);
|
||||
}
|
||||
|
||||
@Post('/activate')
|
||||
@GlobalScope('license:manage')
|
||||
async activateLicense(req: LicenseRequest.Activate) {
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
import { Service } from 'typedi';
|
||||
import axios from 'axios';
|
||||
|
||||
import { Logger } from '@/Logger';
|
||||
import { License } from '@/License';
|
||||
import { InternalHooks } from '@/InternalHooks';
|
||||
import type { User } from '@db/entities/User';
|
||||
import { WorkflowRepository } from '@db/repositories/workflow.repository';
|
||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||
import { UrlService } from '@/services/url.service';
|
||||
|
||||
type LicenseError = Error & { errorId?: keyof typeof LicenseErrors };
|
||||
|
||||
@@ -24,6 +28,7 @@ export class LicenseService {
|
||||
private readonly license: License,
|
||||
private readonly internalHooks: InternalHooks,
|
||||
private readonly workflowRepository: WorkflowRepository,
|
||||
private readonly urlService: UrlService,
|
||||
) {}
|
||||
|
||||
async getLicenseData() {
|
||||
@@ -45,6 +50,16 @@ export class LicenseService {
|
||||
};
|
||||
}
|
||||
|
||||
async requestEnterpriseTrial(user: User) {
|
||||
await axios.post('https://enterprise.n8n.io/enterprise-trial', {
|
||||
licenseType: 'enterprise',
|
||||
firstName: user.firstName,
|
||||
lastName: user.lastName,
|
||||
email: user.email,
|
||||
instanceUrl: this.urlService.getWebhookBaseUrl(),
|
||||
});
|
||||
}
|
||||
|
||||
getManagementJwt(): string {
|
||||
return this.license.getManagementJwt();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user