feat(): enable custom domain usage (#9911)

# Content
- Introduce the `workspaceUrls` property. It contains two
sub-properties: `customUrl, subdomainUrl`. These endpoints are used to
access the workspace. Even if the `workspaceUrls` is invalid for
multiple reasons, the `subdomainUrl` remains valid.
- Introduce `ResolveField` workspaceEndpoints to avoid unnecessary URL
computation on the frontend part.
- Add a `forceSubdomainUrl` to avoid custom URL using a query parameter
This commit is contained in:
Antoine Moreaux
2025-02-07 14:34:26 +01:00
committed by GitHub
parent 3cc66fe712
commit 68183b7c85
87 changed files with 645 additions and 373 deletions

View File

@ -29,7 +29,7 @@ export class EmailVerificationResolver {
return await this.emailVerificationService.resendEmailVerificationToken(
resendEmailVerificationTokenInput.email,
workspace.subdomain,
workspace,
);
}
}

View File

@ -21,6 +21,7 @@ import {
import { EmailService } from 'src/engine/core-modules/email/email.service';
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
import { UserService } from 'src/engine/core-modules/user/services/user.service';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
@Injectable()
// eslint-disable-next-line @nx/workspace-inject-workspace-repository
@ -38,7 +39,7 @@ export class EmailVerificationService {
async sendVerificationEmail(
userId: string,
email: string,
subdomain: string,
workspace: Pick<Workspace, 'subdomain' | 'hostname'>,
) {
if (!this.environmentService.get('IS_EMAIL_VERIFICATION_REQUIRED')) {
return { success: false };
@ -51,7 +52,7 @@ export class EmailVerificationService {
this.domainManagerService.buildEmailVerificationURL({
emailVerificationToken,
email,
subdomain,
workspace,
});
const emailData = {
@ -80,7 +81,10 @@ export class EmailVerificationService {
return { success: true };
}
async resendEmailVerificationToken(email: string, subdomain: string) {
async resendEmailVerificationToken(
email: string,
workspace: Pick<Workspace, 'subdomain' | 'hostname'>,
) {
if (!this.environmentService.get('IS_EMAIL_VERIFICATION_REQUIRED')) {
throw new EmailVerificationException(
'Email verification token cannot be sent because email verification is not required',
@ -121,7 +125,7 @@ export class EmailVerificationService {
await this.appTokenRepository.delete(existingToken.id);
}
await this.sendVerificationEmail(user.id, email, subdomain);
await this.sendVerificationEmail(user.id, email, workspace);
return { success: true };
}