Skip to content

fix(flutter): propagate auth failures instead of reporting success (FR-25942)#140

Closed
dianaKhortiuk-frontegg wants to merge 1 commit into
masterfrom
fix/flutter-propagate-auth-errors
Closed

fix(flutter): propagate auth failures instead of reporting success (FR-25942)#140
dianaKhortiuk-frontegg wants to merge 1 commit into
masterfrom
fix/flutter-propagate-auth-errors

Conversation

@dianaKhortiuk-frontegg

Copy link
Copy Markdown
Collaborator

FR-25942 — auth failures reported as success

The native login/directLoginAction callbacks are ((Exception?) -> Unit)? on Android and Result-based (CompletionHandler/LogoutHandler) on iOS, but the Flutter plugin ignored the error and always called result.success(null). A cancelled or failed authentication (and logout/switchTenant failures on iOS) therefore surfaced to Dart as a successful call.

Android

  • Added top-level completeAuthResult(error, result, onSuccess) that routes a non-null error through result.error(...)FronteggException.message as the error code, otherwise "unknown" — and only calls onSuccess when there's no error.
  • Wired login, directLoginAction, the socialLogin fallback and customSocialLogin through it.
  • logout (() -> Unit, no error) and switchTenant ((Boolean) -> Unit, already mapped to success/error) were already correct — left as-is.
  • Made the helper top-level so it's unit-testable without a Context/Activity (which can't be mocked in this toolchain).

iOS

  • Replaced 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 (the same pattern already used by stepUp and login).

Tests

  • AuthResultPropagationTest (Android): null error → onSuccess; generic Exceptionresult.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/login code and pass a swiftc -parse syntax 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.

…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).
@dianaKhortiuk-frontegg

Copy link
Copy Markdown
Collaborator Author

Superseded by #142, which combines FR-25941/42/43/44 into a single PR. Branch kept.

@github-actions github-actions Bot mentioned this pull request Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant