Skip to content

Commit a5b5e75

Browse files
committed
Apply code review suggestions
1 parent 11bddaa commit a5b5e75

3 files changed

Lines changed: 7 additions & 28 deletions

File tree

src/auth/views/Login.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,16 @@ const LoginView = ({ params }: LoginViewProps) => {
112112
};
113113
}, []);
114114

115+
const isMain = isMainSchema();
116+
const passwordLoginMode = externalAuthenticationsStaging?.shop?.passwordLoginMode;
117+
const passwordLoginEnabled = isMain || passwordLoginMode === PasswordLoginModeEnum.ENABLED;
118+
115119
return (
116120
<LoginPage
117121
errors={errors}
118122
disabled={authenticating}
119123
externalAuthentications={externalAuthentications?.shop?.availableExternalAuthentications}
120-
passwordLoginEnabled={
121-
isMainSchema() ||
122-
(externalAuthenticationsStaging?.shop?.passwordLoginMode !==
123-
PasswordLoginModeEnum.DISABLED &&
124-
externalAuthenticationsStaging?.shop?.passwordLoginMode !==
125-
PasswordLoginModeEnum.CUSTOMERS_ONLY)
126-
}
124+
passwordLoginEnabled={passwordLoginEnabled}
127125
loading={externalAuthenticationsLoading || authenticating}
128126
onExternalAuthentication={handleRequestExternalAuthentication}
129127
onSubmit={handleSubmit}

src/fragments/shop.staging.ts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,7 @@ import { gql } from "@apollo/client";
22

33
export const shopFragment = gql`
44
fragment ShopStaging on Shop {
5-
companyAddress {
6-
...Address
7-
}
8-
countries {
9-
code
10-
country
11-
}
12-
customerSetPasswordUrl
13-
defaultMailSenderAddress
14-
defaultMailSenderName
15-
description
16-
domain {
17-
host
18-
}
19-
name
20-
reserveStockDurationAnonymousUser
21-
reserveStockDurationAuthenticatedUser
22-
limitQuantityPerCheckout
23-
enableAccountConfirmationByEmail
24-
useLegacyUpdateWebhookEmission
25-
preserveAllAddressFields
5+
...Shop
266
passwordLoginMode
277
}
288
`;

src/siteSettings/components/SiteSettingsPage/SiteSettingsPage.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ const SiteSettingsPage = (props: SiteSettingsPageProps) => {
100100
emailConfirmation: shop?.enableAccountConfirmationByEmail ?? false,
101101
useLegacyUpdateWebhookEmission: shop?.useLegacyUpdateWebhookEmission ?? true,
102102
preserveAllAddressFields: shop?.preserveAllAddressFields ?? false,
103+
// Force staging type to access the new field. Once field is available in main schema, casting should be removed.
103104
passwordLoginMode:
104105
(isStagingSchema() && (shop as SiteSettingsStagingQuery["shop"])?.passwordLoginMode) ||
105106
PasswordLoginModeEnum.ENABLED,

0 commit comments

Comments
 (0)