@@ -23,6 +23,7 @@ interface LoginCardProps {
2323 disabled : boolean ;
2424 loading : boolean ;
2525 externalAuthentications ?: AvailableExternalAuthenticationsQuery [ "shop" ] [ "availableExternalAuthentications" ] ;
26+ passwordLoginEnabled : boolean ;
2627 onExternalAuthentication : ( pluginId : string ) => void ;
2728 onSubmit : ( event : LoginFormData ) => SubmitPromise ;
2829 lastLoginMethod : LastLoginMethod ;
@@ -34,6 +35,7 @@ const LoginPage = (props: LoginCardProps) => {
3435 disabled,
3536 loading,
3637 externalAuthentications = [ ] ,
38+ passwordLoginEnabled,
3739 onExternalAuthentication,
3840 onSubmit,
3941 lastLoginMethod,
@@ -65,79 +67,95 @@ const LoginPage = (props: LoginCardProps) => {
6567 < Text color = "critical2" > { getErrorMessage ( error , intl ) } </ Text >
6668 </ Box >
6769 ) ) }
68- < Input
69- autoFocus
70- width = "100%"
71- autoComplete = "email"
72- label = { intl . formatMessage ( commonMessages . email ) }
73- id = "email"
74- name = "email"
75- onChange = { handleChange }
76- value = { data . email }
77- data-test-id = "email"
78- spellCheck = { false }
79- disabled = { disabled }
80- required
81- />
82- < FormSpacer />
83- < Input
84- width = "100%"
85- label = { intl . formatMessage ( {
86- id : "5sg7KC" ,
87- defaultMessage : "Password" ,
88- } ) }
89- id = "password"
90- name = "password"
91- autoComplete = "current-password"
92- onChange = { handleChange }
93- type = { showPassword ? "text" : "password" }
94- value = { data . password }
95- data-test-id = "password"
96- spellCheck = { false }
97- disabled = { disabled }
98- endAdornment = {
99- < Button
100- icon = {
101- < EyeIcon onPointerEnterCapture = { undefined } onPointerLeaveCapture = { undefined } />
70+ { passwordLoginEnabled && (
71+ < >
72+ < Input
73+ autoFocus
74+ width = "100%"
75+ autoComplete = "email"
76+ label = { intl . formatMessage ( commonMessages . email ) }
77+ id = "email"
78+ name = "email"
79+ onChange = { handleChange }
80+ value = { data . email }
81+ data-test-id = "email"
82+ spellCheck = { false }
83+ disabled = { disabled }
84+ required
85+ />
86+ < FormSpacer />
87+ < Input
88+ width = "100%"
89+ label = { intl . formatMessage ( {
90+ id : "5sg7KC" ,
91+ defaultMessage : "Password" ,
92+ } ) }
93+ id = "password"
94+ name = "password"
95+ autoComplete = "current-password"
96+ onChange = { handleChange }
97+ type = { showPassword ? "text" : "password" }
98+ value = { data . password }
99+ data-test-id = "password"
100+ spellCheck = { false }
101+ disabled = { disabled }
102+ endAdornment = {
103+ < Button
104+ icon = {
105+ < EyeIcon
106+ onPointerEnterCapture = { undefined }
107+ onPointerLeaveCapture = { undefined }
108+ />
109+ }
110+ onMouseDown = { ( ) => setShowPassword ( true ) }
111+ onMouseUp = { ( ) => setShowPassword ( false ) }
112+ variant = "tertiary"
113+ type = "button"
114+ />
102115 }
103- onMouseDown = { ( ) => setShowPassword ( true ) }
104- onMouseUp = { ( ) => setShowPassword ( false ) }
105- variant = "tertiary"
106- type = "button"
116+ required
107117 />
108- }
109- required
110- />
111- < Link to = { passwordResetUrl } >
112- < Text className = { classes . link } fontSize = { 3 } data-test-id = "reset-password-link" >
118+ < Link to = { passwordResetUrl } >
119+ < Text className = { classes . link } fontSize = { 3 } data-test-id = "reset-password-link" >
120+ < FormattedMessage
121+ id = "3tbL7x"
122+ defaultMessage = "Forgot password?"
123+ description = "description"
124+ />
125+ </ Text >
126+ </ Link >
127+
128+ < div className = { classes . buttonContainer } >
129+ < ButtonWithLoader
130+ width = "100%"
131+ disabled = { disabled }
132+ variant = "primary"
133+ type = "submit"
134+ transitionState = { loading ? "loading" : "default" }
135+ data-test-id = "submit"
136+ position = "relative"
137+ >
138+ { showLastLoginIndicatorForPassword && < LastLoginIndicator /> }
139+ < FormattedMessage id = "AubJ/S" defaultMessage = "Sign in" description = "button" />
140+ </ ButtonWithLoader >
141+ </ div >
142+ </ >
143+ ) }
144+ { ! passwordLoginEnabled && externalAuthentications . length === 0 && (
145+ < Text color = "default2" fontSize = { 3 } >
113146 < FormattedMessage
114- id = "3tbL7x "
115- defaultMessage = "Forgot password? "
116- description = "description "
147+ id = "BtsJ+e "
148+ defaultMessage = "Password login is disabled. Contact your administrator to configure an external authentication method or enable password login. "
149+ description = "empty state message when no login method is available "
117150 />
118151 </ Text >
119- </ Link >
120-
121- < div className = { classes . buttonContainer } >
122- < ButtonWithLoader
123- width = "100%"
124- disabled = { disabled }
125- variant = "primary"
126- type = "submit"
127- transitionState = { loading ? "loading" : "default" }
128- data-test-id = "submit"
129- position = "relative"
130- >
131- { showLastLoginIndicatorForPassword && < LastLoginIndicator /> }
132- < FormattedMessage id = "AubJ/S" defaultMessage = "Sign in" description = "button" />
133- </ ButtonWithLoader >
134- </ div >
152+ ) }
135153 { externalAuthentications . map ( externalAuthentication => (
136154 < Fragment key = { externalAuthentication . id } >
137155 < FormSpacer />
138156 < ButtonWithLoader
139157 width = "100%"
140- variant = "secondary"
158+ variant = { passwordLoginEnabled ? "secondary" : "primary" }
141159 onClick = { ( ) => {
142160 onExternalAuthentication ( externalAuthentication . id ) ;
143161 setOptimisticLoaderAuthId ( externalAuthentication . id ) ;
0 commit comments