fix(flutter): propagate auth failures instead of reporting success (FR-25942)#140
Closed
dianaKhortiuk-frontegg wants to merge 1 commit into
Closed
fix(flutter): propagate auth failures instead of reporting success (FR-25942)#140dianaKhortiuk-frontegg wants to merge 1 commit into
dianaKhortiuk-frontegg wants to merge 1 commit into
Conversation
…R-25942)
Android login/directLoginAction native callbacks are ((Exception?) -> Unit)?
and iOS login/directLoginAction/logout/switchTenant use Result callbacks, but
the plugin ignored the error and always called result.success(null). A cancelled
or failed authentication therefore surfaced to Dart as success.
- Android: add top-level completeAuthResult(error, result, onSuccess) that routes
a non-null error through result.error(...) (FronteggException message as code,
else "unknown"); wire login, directLoginAction, socialLogin fallback and
customSocialLogin through it. logout ((): Unit) and switchTenant ((Boolean))
already have no error / are handled. Unit-tested via AuthResultPropagationTest.
- iOS: replace the swallowing { _ in result(nil) } completion blocks in
directLoginAction/directLogin/socialLogin/customSocialLogin, logout and
switchTenant with the existing success/failure switch that maps FronteggError
to a FlutterError (matching stepUp/login).
Collaborator
Author
|
Superseded by #142, which combines FR-25941/42/43/44 into a single PR. Branch kept. |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FR-25942 — auth failures reported as success
The native
login/directLoginActioncallbacks are((Exception?) -> Unit)?on Android andResult-based (CompletionHandler/LogoutHandler) on iOS, but the Flutter plugin ignored the error and always calledresult.success(null). A cancelled or failed authentication (andlogout/switchTenantfailures on iOS) therefore surfaced to Dart as a successful call.Android
completeAuthResult(error, result, onSuccess)that routes a non-null error throughresult.error(...)—FronteggException.messageas the error code, otherwise"unknown"— and only callsonSuccesswhen there's no error.login,directLoginAction, thesocialLoginfallback andcustomSocialLoginthrough it.logout(() -> Unit, no error) andswitchTenant((Boolean) -> Unit, already mapped to success/error) were already correct — left as-is.Context/Activity(which can't be mocked in this toolchain).iOS
{ _ in result(nil) }completion blocks indirectLoginAction,directLogin,socialLogin,customSocialLogin,logoutandswitchTenantwith the existingsuccess/failureswitch that mapsFronteggErrorto aFlutterError(the same pattern already used bystepUpandlogin).Tests
AuthResultPropagationTest(Android): null error →onSuccess; genericException→result.error("unknown", message);FronteggException→ its message as the error code. RED → GREEN verified via:frontegg_flutter:testDebugUnitTest.Note
iOS changes are type-confirmed pattern matches against the existing
stepUp/logincode and pass aswiftc -parsesyntax check, but were not compiled in a full iOS build in this environment (no iOS Flutter build harness). Please let CI / an iOS build confirm before merge.