Skip to content

Commit 7ce938e

Browse files
authored
chore: remove dev feature guard of the collect user profile feature (#7694)
chore: remove dev feature guard of collect user profile feature
1 parent 98e3929 commit 7ce938e

File tree

14 files changed

+44
-63
lines changed

14 files changed

+44
-63
lines changed

packages/console/src/pages/SignInExperience/PageContent/index.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { useParams } from 'react-router-dom';
88

99
import SubmitFormChangesActionBar from '@/components/SubmitFormChangesActionBar';
1010
import UnsavedChangesAlertModal from '@/components/UnsavedChangesAlertModal';
11-
import { isDevFeaturesEnabled } from '@/consts/env';
1211
import ConfirmModal from '@/ds-components/ConfirmModal';
1312
import TabNav, { TabNavItem } from '@/ds-components/TabNav';
1413
import useApi from '@/hooks/use-api';
@@ -132,11 +131,9 @@ function PageContent({ data, onSignInExperienceUpdated }: Props) {
132131
>
133132
{t('sign_in_exp.tabs.sign_up_and_sign_in')}
134133
</PageTab>
135-
{isDevFeaturesEnabled && (
136-
<PageTab href="../collect-user-profile">
137-
{t('sign_in_exp.tabs.collect_user_profile')}
138-
</PageTab>
139-
)}
134+
<PageTab href="../collect-user-profile">
135+
{t('sign_in_exp.tabs.collect_user_profile')}
136+
</PageTab>
140137
<PageTab href="../content" errorCount={getContentErrorCount(errors)}>
141138
{t('sign_in_exp.tabs.content')}
142139
</PageTab>
@@ -147,9 +144,7 @@ function PageContent({ data, onSignInExperienceUpdated }: Props) {
147144
<form>
148145
<Branding isActive={tab === SignInExperienceTab.Branding} />
149146
<SignUpAndSignIn isActive={tab === SignInExperienceTab.SignUpAndSignIn} data={data} />
150-
{isDevFeaturesEnabled && (
151-
<CollectUserProfile isActive={tab === SignInExperienceTab.CollectUserProfile} />
152-
)}
147+
<CollectUserProfile isActive={tab === SignInExperienceTab.CollectUserProfile} />
153148
<Content isActive={tab === SignInExperienceTab.Content} />
154149
</form>
155150
</FormProvider>

packages/core/src/libraries/sign-in-experience/index.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ describe('getFullSignInExperience()', () => {
207207
socialSignInConnectorTargets: ['github', 'facebook', 'google'],
208208
});
209209
getLogtoConnectors.mockResolvedValueOnce([mockGoogleConnector, mockGithubConnector]);
210+
findAllCustomProfileFields.mockResolvedValueOnce(mockCustomProfileFields);
210211
mockSsoConnectorLibrary.getAvailableSsoConnectors.mockResolvedValueOnce([
211212
wellConfiguredSsoConnector,
212213
]);
@@ -237,6 +238,7 @@ describe('getFullSignInExperience()', () => {
237238
connectorId: 'google',
238239
},
239240
captchaConfig: undefined,
241+
customProfileFields: mockCustomProfileFields,
240242
forgotPassword: {
241243
email: false,
242244
phone: false,

packages/core/src/libraries/sign-in-experience/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type {
88
SsoConnectorMetadata,
99
} from '@logto/schemas';
1010
import { ConnectorType, ForgotPasswordMethod, ReservedPlanId } from '@logto/schemas';
11-
import { cond, conditional, deduplicate, pick, trySafe } from '@silverhand/essentials';
11+
import { deduplicate, pick, trySafe } from '@silverhand/essentials';
1212
import deepmerge from 'deepmerge';
1313

1414
import { type WellKnownCache } from '#src/caches/well-known.js';
@@ -195,7 +195,7 @@ export const createSignInExperienceLibrary = (
195195
getIsDevelopmentTenant(),
196196
getOrganizationOverride(organizationId),
197197
findApplicationSignInExperience(appId),
198-
conditional(EnvSet.values.isDevFeaturesEnabled && findAllCustomProfileFields()),
198+
findAllCustomProfileFields(),
199199
]);
200200

201201
// Always return empty array if single-sign-on is disabled
@@ -310,7 +310,7 @@ export const createSignInExperienceLibrary = (
310310
isDevelopmentTenant,
311311
googleOneTap: getGoogleOneTap(),
312312
captchaConfig: await getCaptchaConfig(),
313-
...cond(EnvSet.values.isDevFeaturesEnabled && customProfileFields && { customProfileFields }),
313+
customProfileFields,
314314
};
315315
};
316316

packages/core/src/routes/custom-profile-fields.openapi.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
{
44
"name": "Custom profile fields",
55
"description": "An admin feature used to create a customized user profile form, which is used to collect additional user information upon successful registrations."
6-
},
7-
{
8-
"name": "Dev feature"
96
}
107
],
118
"paths": {

packages/core/src/routes/experience/experience.openapi.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@
121121
},
122122
"/api/experience/interaction": {
123123
"get": {
124-
"tags": ["Dev feature"],
125124
"operationId": "GetInteraction",
126125
"summary": "Get public interaction data",
127126
"description": "Get the public interaction data.",

packages/core/src/routes/experience/index.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import koaGuard from '#src/middleware/koa-guard.js';
1919
import koaInteractionDetails from '#src/middleware/koa-interaction-details.js';
2020
import assertThat from '#src/utils/assert-that.js';
2121

22-
import { EnvSet } from '../../env-set/index.js';
2322
import { type AnonymousRouter, type RouterInitArgs } from '../types.js';
2423

2524
import experienceAnonymousRoutes from './anonymous-routes/index.js';
@@ -192,23 +191,20 @@ export default function experienceApiRoutes<T extends AnonymousRouter>(
192191
}
193192
);
194193

195-
// TODO: @charles remove dev feature guard
196-
if (EnvSet.values.isDevFeaturesEnabled) {
197-
experienceRouter.get(
198-
`${experienceRoutes.interaction}`,
199-
koaGuard({
200-
status: [200],
201-
response: sanitizedInteractionStorageGuard,
202-
}),
203-
async (ctx, next) => {
204-
const { experienceInteraction } = ctx;
194+
experienceRouter.get(
195+
`${experienceRoutes.interaction}`,
196+
koaGuard({
197+
status: [200],
198+
response: sanitizedInteractionStorageGuard,
199+
}),
200+
async (ctx, next) => {
201+
const { experienceInteraction } = ctx;
205202

206-
ctx.body = experienceInteraction.toSanitizedJson();
207-
ctx.status = 200;
208-
return next();
209-
}
210-
);
211-
}
203+
ctx.body = experienceInteraction.toSanitizedJson();
204+
ctx.status = 200;
205+
return next();
206+
}
207+
);
212208

213209
passwordVerificationRoutes(experienceRouter, tenant);
214210
verificationCodeRoutes(experienceRouter, tenant);

packages/core/src/routes/init.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ const createRouters = (tenant: TenantContext) => {
113113
oneTimeTokenRoutes(managementRouter, tenant);
114114
captchaProviderRoutes(managementRouter, tenant);
115115
sentinelActivitiesRoutes(managementRouter, tenant);
116-
if (EnvSet.values.isDevFeaturesEnabled) {
117-
customProfileFieldsRoutes(managementRouter, tenant);
118-
}
116+
customProfileFieldsRoutes(managementRouter, tenant);
119117
secretsRoutes(managementRouter, tenant);
120118

121119
// General anonymous router for publicly accessible APIs

packages/core/src/routes/swagger/utils/documents.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const additionalTags = Object.freeze(
6666
'SAML applications auth flow',
6767
'One-time tokens',
6868
'Captcha provider',
69-
EnvSet.values.isDevFeaturesEnabled && 'Custom profile fields'
69+
'Custom profile fields'
7070
)
7171
);
7272

packages/core/src/routes/swagger/utils/general.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ const tagMap = new Map([
3838
['saml-applications', 'SAML applications'],
3939
['saml', 'SAML applications auth flow'],
4040
['one-time-tokens', 'One-time tokens'],
41+
['custom-profile-fields', 'Custom profile fields'],
4142
]);
4243

4344
if (EnvSet.values.isDevFeaturesEnabled) {
44-
tagMap.set('custom-profile-fields', 'Custom profile fields');
45+
// TagMap.set('foo-bar', 'Foo bar');
4546
}
4647

4748
/**

packages/core/src/routes/swagger/utils/operation-id.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,7 @@ const methodToVerb = Object.freeze({
2727

2828
type RouteDictionary = Record<`${OpenAPIV3.HttpMethods} ${string}`, string>;
2929

30-
const devFeatureCustomRoutes: RouteDictionary = Object.freeze({
31-
'get /custom-profile-fields/:name': 'GetCustomProfileFieldByName',
32-
'put /custom-profile-fields/:name': 'UpdateCustomProfileFieldByName',
33-
'delete /custom-profile-fields/:name': 'DeleteCustomProfileFieldByName',
34-
'post /custom-profile-fields/batch': 'CreateCustomProfileFieldsBatch',
35-
'post /custom-profile-fields/properties/sie-order': 'UpdateCustomProfileFieldsSieOrder',
36-
});
30+
const devFeatureCustomRoutes: RouteDictionary = Object.freeze({});
3731

3832
export const customRoutes: Readonly<RouteDictionary> = Object.freeze({
3933
// Authn
@@ -94,6 +88,12 @@ export const customRoutes: Readonly<RouteDictionary> = Object.freeze({
9488
'post /one-time-tokens/verify': 'VerifyOneTimeToken',
9589
// Sentinel activities
9690
'post /sentinel-activities/delete': 'DeleteSentinelActivities',
91+
// Collect user profile
92+
'get /custom-profile-fields/:name': 'GetCustomProfileFieldByName',
93+
'put /custom-profile-fields/:name': 'UpdateCustomProfileFieldByName',
94+
'delete /custom-profile-fields/:name': 'DeleteCustomProfileFieldByName',
95+
'post /custom-profile-fields/batch': 'CreateCustomProfileFieldsBatch',
96+
'post /custom-profile-fields/properties/sie-order': 'UpdateCustomProfileFieldsSieOrder',
9797
...(EnvSet.values.isDevFeaturesEnabled ? devFeatureCustomRoutes : {}),
9898
} satisfies RouteDictionary); // Key assertion doesn't work without `satisfies`
9999

0 commit comments

Comments
 (0)