@@ -31,6 +31,7 @@ import LoginForm from './LoginForm';
31
31
import type { InputHandle } from './LoginForm/types' ;
32
32
import SignInPageLayout from './SignInPageLayout' ;
33
33
import type { SignInPageLayoutRef } from './SignInPageLayout/types' ;
34
+ import SignUpWelcomeForm from './SignUpWelcomeForm' ;
34
35
import UnlinkLoginForm from './UnlinkLoginForm' ;
35
36
import ValidateCodeForm from './ValidateCodeForm' ;
36
37
@@ -61,6 +62,7 @@ type RenderOption = {
61
62
shouldInitiateSAMLLogin : boolean ;
62
63
shouldShowWelcomeHeader : boolean ;
63
64
shouldShowWelcomeText : boolean ;
65
+ shouldShouldSignUpWelcomeForm : boolean ;
64
66
} ;
65
67
66
68
type GetRenderOptionsParams = {
@@ -71,6 +73,7 @@ type GetRenderOptionsParams = {
71
73
isUsingMagicCode : boolean ;
72
74
hasInitiatedSAMLLogin : boolean ;
73
75
shouldShowAnotherLoginPageOpenedMessage : boolean ;
76
+ credentials : OnyxEntry < Credentials > ;
74
77
} ;
75
78
76
79
/**
@@ -90,6 +93,7 @@ function getRenderOptions({
90
93
isUsingMagicCode,
91
94
hasInitiatedSAMLLogin,
92
95
shouldShowAnotherLoginPageOpenedMessage,
96
+ credentials,
93
97
} : GetRenderOptionsParams ) : RenderOption {
94
98
const hasAccount = ! isEmptyObject ( account ) ;
95
99
const isSAMLEnabled = ! ! account ?. isSAMLEnabled ;
@@ -107,22 +111,33 @@ function getRenderOptions({
107
111
Session . clearSignInData ( ) ;
108
112
}
109
113
114
+ // Show the Welcome form if a user is signing up for a new account in a domain that is not controlled
115
+ const shouldShouldSignUpWelcomeForm = Boolean ( credentials ?. login ) && ! account ?. validated && ! account ?. accountExists && ! account ?. domainControlled ;
110
116
const shouldShowLoginForm = ! shouldShowAnotherLoginPageOpenedMessage && ! hasLogin && ! hasValidateCode ;
111
117
const shouldShowEmailDeliveryFailurePage = hasLogin && hasEmailDeliveryFailure && ! shouldShowChooseSSOOrMagicCode && ! shouldInitiateSAMLLogin ;
112
118
const isUnvalidatedSecondaryLogin = hasLogin && ! isPrimaryLogin && ! account ?. validated && ! hasEmailDeliveryFailure ;
113
119
const shouldShowValidateCodeForm =
114
- hasAccount && ( hasLogin || hasValidateCode ) && ! isUnvalidatedSecondaryLogin && ! hasEmailDeliveryFailure && ! shouldShowChooseSSOOrMagicCode && ! isSAMLRequired ;
115
- const shouldShowWelcomeHeader = shouldShowLoginForm || shouldShowValidateCodeForm || shouldShowChooseSSOOrMagicCode || isUnvalidatedSecondaryLogin ;
116
- const shouldShowWelcomeText = shouldShowLoginForm || shouldShowValidateCodeForm || shouldShowChooseSSOOrMagicCode || shouldShowAnotherLoginPageOpenedMessage ;
120
+ ! shouldShouldSignUpWelcomeForm &&
121
+ hasAccount &&
122
+ ( hasLogin || hasValidateCode ) &&
123
+ ! isUnvalidatedSecondaryLogin &&
124
+ ! hasEmailDeliveryFailure &&
125
+ ! shouldShowChooseSSOOrMagicCode &&
126
+ ! isSAMLRequired ;
127
+ const shouldShowWelcomeHeader = shouldShowLoginForm || shouldShowValidateCodeForm || shouldShowChooseSSOOrMagicCode || isUnvalidatedSecondaryLogin || shouldShouldSignUpWelcomeForm ;
128
+ const shouldShowWelcomeText =
129
+ shouldShowLoginForm || shouldShowValidateCodeForm || shouldShowChooseSSOOrMagicCode || shouldShowAnotherLoginPageOpenedMessage || shouldShouldSignUpWelcomeForm ;
130
+
117
131
return {
118
132
shouldShowLoginForm,
119
133
shouldShowEmailDeliveryFailurePage,
120
- shouldShowUnlinkLoginForm : isUnvalidatedSecondaryLogin ,
134
+ shouldShowUnlinkLoginForm : ! shouldShouldSignUpWelcomeForm && isUnvalidatedSecondaryLogin ,
121
135
shouldShowValidateCodeForm,
122
136
shouldShowChooseSSOOrMagicCode,
123
137
shouldInitiateSAMLLogin,
124
138
shouldShowWelcomeHeader,
125
139
shouldShowWelcomeText,
140
+ shouldShouldSignUpWelcomeForm,
126
141
} ;
127
142
}
128
143
@@ -181,6 +196,7 @@ function SignInPageInner({credentials, account, activeClients = [], preferredLoc
181
196
shouldInitiateSAMLLogin,
182
197
shouldShowWelcomeHeader,
183
198
shouldShowWelcomeText,
199
+ shouldShouldSignUpWelcomeForm,
184
200
} = getRenderOptions ( {
185
201
hasLogin : ! ! credentials ?. login ,
186
202
hasValidateCode : ! ! credentials ?. validateCode ,
@@ -189,6 +205,7 @@ function SignInPageInner({credentials, account, activeClients = [], preferredLoc
189
205
isUsingMagicCode,
190
206
hasInitiatedSAMLLogin,
191
207
shouldShowAnotherLoginPageOpenedMessage,
208
+ credentials,
192
209
} ) ;
193
210
194
211
if ( shouldInitiateSAMLLogin ) {
@@ -200,6 +217,11 @@ function SignInPageInner({credentials, account, activeClients = [], preferredLoc
200
217
let welcomeText = '' ;
201
218
const headerText = translate ( 'login.hero.header' ) ;
202
219
220
+ const userLogin = Str . removeSMSDomain ( credentials ?. login ?? '' ) ;
221
+
222
+ // replacing spaces with "hard spaces" to prevent breaking the number
223
+ const userLoginToDisplay = Str . isSMSLogin ( userLogin ) ? formatPhoneNumber ( userLogin ) : userLogin ;
224
+
203
225
if ( shouldShowAnotherLoginPageOpenedMessage ) {
204
226
welcomeHeader = translate ( 'welcomeText.anotherLoginPageIsOpen' ) ;
205
227
welcomeText = translate ( 'welcomeText.anotherLoginPageIsOpenExplanation' ) ;
@@ -212,21 +234,10 @@ function SignInPageInner({credentials, account, activeClients = [], preferredLoc
212
234
welcomeHeader = shouldUseNarrowLayout ? '' : translate ( 'welcomeText.welcome' ) ;
213
235
welcomeText = isUsingRecoveryCode ? translate ( 'validateCodeForm.enterRecoveryCode' ) : translate ( 'validateCodeForm.enterAuthenticatorCode' ) ;
214
236
} else {
215
- const userLogin = Str . removeSMSDomain ( credentials ?. login ?? '' ) ;
216
-
217
- // replacing spaces with "hard spaces" to prevent breaking the number
218
- const userLoginToDisplay = Str . isSMSLogin ( userLogin ) ? formatPhoneNumber ( userLogin ) . replace ( / / g, '\u00A0' ) : userLogin ;
219
- if ( account ?. validated ) {
220
- welcomeHeader = shouldUseNarrowLayout ? '' : translate ( 'welcomeText.welcome' ) ;
221
- welcomeText = shouldUseNarrowLayout
222
- ? `${ translate ( 'welcomeText.welcome' ) } ${ translate ( 'welcomeText.welcomeEnterMagicCode' , { login : userLoginToDisplay } ) } `
223
- : translate ( 'welcomeText.welcomeEnterMagicCode' , { login : userLoginToDisplay } ) ;
224
- } else {
225
- welcomeHeader = shouldUseNarrowLayout ? '' : translate ( 'welcomeText.welcome' ) ;
226
- welcomeText = shouldUseNarrowLayout
227
- ? `${ translate ( 'welcomeText.welcome' ) } ${ translate ( 'welcomeText.newFaceEnterMagicCode' , { login : userLoginToDisplay } ) } `
228
- : translate ( 'welcomeText.newFaceEnterMagicCode' , { login : userLoginToDisplay } ) ;
229
- }
237
+ welcomeHeader = shouldUseNarrowLayout ? '' : translate ( 'welcomeText.welcome' ) ;
238
+ welcomeText = shouldUseNarrowLayout
239
+ ? `${ translate ( 'welcomeText.welcome' ) } ${ translate ( 'welcomeText.welcomeEnterMagicCode' , { login : userLoginToDisplay } ) } `
240
+ : translate ( 'welcomeText.welcomeEnterMagicCode' , { login : userLoginToDisplay } ) ;
230
241
}
231
242
} else if ( shouldShowUnlinkLoginForm || shouldShowEmailDeliveryFailurePage || shouldShowChooseSSOOrMagicCode ) {
232
243
welcomeHeader = shouldUseNarrowLayout ? headerText : translate ( 'welcomeText.welcome' ) ;
@@ -235,6 +246,11 @@ function SignInPageInner({credentials, account, activeClients = [], preferredLoc
235
246
if ( shouldShowEmailDeliveryFailurePage || shouldShowChooseSSOOrMagicCode ) {
236
247
welcomeText = '' ;
237
248
}
249
+ } else if ( shouldShouldSignUpWelcomeForm ) {
250
+ welcomeHeader = shouldUseNarrowLayout ? headerText : translate ( 'welcomeText.welcome' ) ;
251
+ welcomeText = shouldUseNarrowLayout
252
+ ? `${ translate ( 'welcomeText.welcomeWithoutExclamation' ) } ${ translate ( 'welcomeText.welcomeNewFace' , { login : userLoginToDisplay } ) } `
253
+ : translate ( 'welcomeText.welcomeNewFace' , { login : userLoginToDisplay } ) ;
238
254
} else if ( ! shouldInitiateSAMLLogin && ! hasInitiatedSAMLLogin ) {
239
255
Log . warn ( 'SignInPage in unexpected state!' ) ;
240
256
}
@@ -269,6 +285,7 @@ function SignInPageInner({credentials, account, activeClients = [], preferredLoc
269
285
blurOnSubmit = { account ?. validated === false }
270
286
scrollPageToTop = { signInPageLayoutRef . current ?. scrollPageToTop }
271
287
/>
288
+ { shouldShouldSignUpWelcomeForm && < SignUpWelcomeForm /> }
272
289
{ shouldShowValidateCodeForm && (
273
290
< ValidateCodeForm
274
291
isVisible = { ! shouldShowAnotherLoginPageOpenedMessage }
0 commit comments