Fix wrong path used by backend (#14352)
After moving a section on the frontend, this broke the path that was sent by email on the backend. This kind of error comes back every ~2-3 month under different forms so we need a more robust solution: I moved routes to the shared folder, that way we will share one common source of truth between the frontend and the backend. Fixes #14343
This commit is contained in:
+5
-2
@@ -9,6 +9,8 @@ import {
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
|
||||
import { Response } from 'express';
|
||||
import { SettingsPath } from 'twenty-shared/types';
|
||||
import { getSettingsPath } from 'twenty-shared/utils';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
import {
|
||||
@@ -115,7 +117,8 @@ export class GoogleAPIsAuthController {
|
||||
this.domainManagerService
|
||||
.buildWorkspaceURL({
|
||||
workspace,
|
||||
pathname: redirectLocation || '/settings/accounts',
|
||||
pathname:
|
||||
redirectLocation || getSettingsPath(SettingsPath.Accounts),
|
||||
})
|
||||
.toString(),
|
||||
);
|
||||
@@ -127,7 +130,7 @@ export class GoogleAPIsAuthController {
|
||||
subdomain: this.twentyConfigService.get('DEFAULT_SUBDOMAIN'),
|
||||
customDomain: null,
|
||||
},
|
||||
pathname: '/settings/accounts',
|
||||
pathname: getSettingsPath(SettingsPath.Accounts),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
+5
-2
@@ -9,6 +9,8 @@ import {
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
|
||||
import { Response } from 'express';
|
||||
import { AppPath, SettingsPath } from 'twenty-shared/types';
|
||||
import { getSettingsPath } from 'twenty-shared/utils';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
import {
|
||||
@@ -122,7 +124,8 @@ export class MicrosoftAPIsAuthController {
|
||||
this.domainManagerService
|
||||
.buildWorkspaceURL({
|
||||
workspace,
|
||||
pathname: redirectLocation || '/settings/accounts',
|
||||
pathname:
|
||||
redirectLocation || getSettingsPath(SettingsPath.Accounts),
|
||||
})
|
||||
.toString(),
|
||||
);
|
||||
@@ -134,7 +137,7 @@ export class MicrosoftAPIsAuthController {
|
||||
subdomain: this.twentyConfigService.get('DEFAULT_SUBDOMAIN'),
|
||||
customDomain: null,
|
||||
},
|
||||
pathname: '/verify',
|
||||
pathname: AppPath.Verify,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
+2
-1
@@ -13,6 +13,7 @@ import { InjectRepository } from '@nestjs/typeorm';
|
||||
|
||||
import { generateServiceProviderMetadata } from '@node-saml/node-saml';
|
||||
import { Response } from 'express';
|
||||
import { AppPath } from 'twenty-shared/types';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
import {
|
||||
@@ -162,7 +163,7 @@ export class SSOAuthController {
|
||||
this.domainManagerService.getSubdomainAndCustomDomainFromWorkspaceFallbackOnDefaultSubdomain(
|
||||
workspaceIdentityProvider?.workspace,
|
||||
),
|
||||
pathname: '/verify',
|
||||
pathname: AppPath.Verify,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import { render } from '@react-email/render';
|
||||
import { addMilliseconds } from 'date-fns';
|
||||
import ms from 'ms';
|
||||
import { PasswordUpdateNotifyEmail } from 'twenty-emails';
|
||||
import { AppPath } from 'twenty-shared/types';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
@@ -527,7 +528,7 @@ export class AuthService {
|
||||
}) {
|
||||
const url = this.domainManagerService.buildWorkspaceURL({
|
||||
workspace,
|
||||
pathname: '/verify',
|
||||
pathname: AppPath.Verify,
|
||||
searchParams: {
|
||||
loginToken,
|
||||
...(billingCheckoutSessionState ? { billingCheckoutSessionState } : {}),
|
||||
@@ -739,7 +740,7 @@ export class AuthService {
|
||||
));
|
||||
|
||||
const url = this.domainManagerService.buildBaseUrl({
|
||||
pathname: '/welcome',
|
||||
pathname: AppPath.SignInUp,
|
||||
searchParams: {
|
||||
tokenPair: JSON.stringify({
|
||||
accessOrWorkspaceAgnosticToken:
|
||||
@@ -827,7 +828,7 @@ export class AuthService {
|
||||
this.domainManagerService.getSubdomainAndCustomDomainFromWorkspaceFallbackOnDefaultSubdomain(
|
||||
currentWorkspace,
|
||||
),
|
||||
pathname: '/verify',
|
||||
pathname: AppPath.Verify,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -10,6 +10,8 @@ import { addMilliseconds, differenceInMilliseconds } from 'date-fns';
|
||||
import ms from 'ms';
|
||||
import { PasswordResetLinkEmail } from 'twenty-emails';
|
||||
import { type APP_LOCALES } from 'twenty-shared/translations';
|
||||
import { AppPath } from 'twenty-shared/types';
|
||||
import { getAppPath } from 'twenty-shared/utils';
|
||||
import { IsNull, MoreThan, Repository } from 'typeorm';
|
||||
|
||||
import {
|
||||
@@ -139,7 +141,9 @@ export class ResetPasswordService {
|
||||
|
||||
const link = this.domainManagerService.buildWorkspaceURL({
|
||||
workspace,
|
||||
pathname: `/reset-password/${resetToken.passwordResetToken}`,
|
||||
pathname: getAppPath(AppPath.ResetPassword, {
|
||||
passwordResetToken: resetToken.passwordResetToken,
|
||||
}),
|
||||
});
|
||||
|
||||
const emailData = {
|
||||
|
||||
Reference in New Issue
Block a user