Skip to content

Commit 35b81b5

Browse files
Handle the case where user enters a username instead of email
1 parent f369a34 commit 35b81b5

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/jetpack/wpcom/JetpackActivationWPComEmailScreen.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import androidx.compose.material.icons.Icons.Filled
1818
import androidx.compose.material.icons.filled.Clear
1919
import androidx.compose.runtime.Composable
2020
import androidx.compose.runtime.livedata.observeAsState
21-
import androidx.compose.ui.ExperimentalComposeUiApi
2221
import androidx.compose.ui.Modifier
2322
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
2423
import androidx.compose.ui.res.dimensionResource
@@ -47,7 +46,6 @@ fun JetpackActivationWPComEmailScreen(viewModel: JetpackActivationWPComEmailView
4746
}
4847
}
4948

50-
@OptIn(ExperimentalComposeUiApi::class)
5149
@Composable
5250
fun JetpackActivationWPComEmailScreen(
5351
viewState: JetpackActivationWPComEmailViewModel.ViewState,
@@ -115,6 +113,11 @@ fun JetpackActivationWPComEmailScreen(
115113
}
116114
)
117115
)
116+
Spacer(modifier = Modifier.height(dimensionResource(id = R.dimen.minor_100)))
117+
Text(
118+
style = MaterialTheme.typography.caption,
119+
text = stringResource(id = R.string.login_jetpack_connection_create_account)
120+
)
118121
}
119122

120123
Spacer(modifier = Modifier.weight(1f))

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/jetpack/wpcom/JetpackActivationWPComEmailViewModel.kt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,18 @@ class JetpackActivationWPComEmailViewModel @Inject constructor(
106106

107107
when (failure?.type) {
108108
AuthOptionsErrorType.UNKNOWN_USER -> {
109-
if (FeatureFlag.JETPACK_FLOW_ACCOUNT_CREATION.isEnabled() &&
110-
StringUtils.isValidEmail(emailOrUsername)
111-
) {
112-
triggerEvent(
113-
ShowMagicLinkScreen(
114-
emailOrUsername, navArgs.jetpackStatus, isNewWpComAccount = true
109+
when {
110+
!StringUtils.isValidEmail(emailOrUsername) ->
111+
errorMessage.value = R.string.username_not_registered_wpcom
112+
113+
FeatureFlag.JETPACK_FLOW_ACCOUNT_CREATION.isEnabled() ->
114+
triggerEvent(
115+
ShowMagicLinkScreen(
116+
emailOrUsername, navArgs.jetpackStatus, isNewWpComAccount = true
117+
)
115118
)
116-
)
117-
} else {
118-
errorMessage.value = R.string.email_not_registered_wpcom
119+
120+
else -> errorMessage.value = R.string.email_not_registered_wpcom
119121
}
120122
}
121123

WooCommerce/src/main/res/values/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,8 @@
365365
<string name="login_site_credentials_fetching_site">Fetching site…</string>
366366
<string name="login_site_credentials_web_authorization_connection_rejected">Unable to login because application password creation is not approved.</string>
367367
<string name="login_app_login_malformed_link">We couldn\'t process your app login request</string>
368+
<string name="login_jetpack_connection_create_account">If you don\'t have an account, we\'ll use this email to create one.</string>
369+
368370
<!--
369371
My Store View
370372
-->
@@ -3428,6 +3430,7 @@
34283430
<string name="login_magic_link_button">Log in with magic link</string>
34293431

34303432
<string name="email_not_registered_wpcom">Hmm, we can\'t find a WordPress.com account connected to this email address.</string>
3433+
<string name="username_not_registered_wpcom">Hmm, we can\'t find a WordPress.com account connected to this username address. You can enter an email to create a new account</string>
34313434
<string name="login_magic_links_label">We\'ll email you a link that\'ll log you in instantly, no password needed.</string>
34323435
<string name="login_get_link_by_email">Get a login link by email</string>
34333436
<string name="signup_magic_link_message">We’ve emailed you a signup link to create your new WordPress.com account. Check your email on this device, and tap the link in the email you receive from WordPress.com.</string>

0 commit comments

Comments
 (0)