Skip to content

Commit 99ad008

Browse files
Use guard instead of if else
1 parent aa7a587 commit 99ad008

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

WooCommerce/Classes/Authentication/WPComLogin/WPComEmailLoginViewModel.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,16 @@ final class WPComEmailLoginViewModel: ObservableObject {
8787
}
8888
await startAuthentication(email: email, isPasswordlessAccount: passwordless)
8989
} catch {
90-
if allowAccountCreation,
91-
let apiError = error as? WordPressAPIError<WordPressComRestApiEndpointError>,
92-
case let .endpointError(endpointError) = apiError,
93-
endpointError.apiErrorCode == Constants.unknownUserErrorCode {
94-
// The user does not exist yet, trigger magic link flow for account creation
95-
await requestAuthenticationLink(email: email, forAccountCreation: true)
96-
} else {
90+
guard allowAccountCreation,
91+
let apiError = error as? WordPressAPIError<WordPressComRestApiEndpointError>,
92+
case .endpointError(let endpointError) = apiError,
93+
endpointError.apiErrorCode == Constants.unknownUserErrorCode else {
9794
analytics.track(event: .JetpackSetup.loginFlow(step: .emailAddress, failure: error))
9895
onError(error.localizedDescription)
96+
return
9997
}
98+
99+
await requestAuthenticationLink(email: email, forAccountCreation: true)
100100
}
101101
}
102102

0 commit comments

Comments
 (0)