Skip to content

fix(react-native): propagate login and switchTenant failures (FR-25938) - #95

Closed
dianaKhortiuk-frontegg wants to merge 1 commit into
fix/rn-android-currentactivity-npefrom
fix/rn-propagate-auth-errors
Closed

fix(react-native): propagate login and switchTenant failures (FR-25938)#95
dianaKhortiuk-frontegg wants to merge 1 commit into
fix/rn-android-currentactivity-npefrom
fix/rn-propagate-auth-errors

Conversation

@dianaKhortiuk-frontegg

Copy link
Copy Markdown
Collaborator

FR-25938 — login/switchTenant report success on failure; login errors unobservable

Stacked on #94 (FR-25939). Base is fix/rn-android-currentactivity-npe to avoid conflicts on the shared login method — retarget to master once #94 merges.

  • Android: login's callback ignored the Exception? and always resolved ""; switchTenant ignored the SDK callback's Boolean and always resolved the tenant id. Both now go through extracted, unit-tested helpers resolveOrRejectLogin(error, promise) / resolveTenantSwitch(success, tenantId, promise) that reject on failure.
  • iOS: login resolved the string "Failed: …" instead of rejecting; switchTenant ignored the completion result and always resolved. Both now reject(...) with the FronteggError on failure (rejecter made @escaping since the completion escapes).
  • JS: login() was fire-and-forget (result swallowed in console.log). It now returns the promise so callers can await it and observe rejections.

Failure scenario fixed

User cancels login or a tenant switch fails → the app now sees a rejection instead of proceeding as if it succeeded.

Tests

AuthResultPropagationTest (Android): login null-error → resolve, error → LOGIN_ERROR reject; switchTenant true → resolve tenant id, false → SWITCH_TENANT_ERROR reject. RED → GREEN via the example-app Gradle harness.

Note

iOS Swift verified via swiftc -parse; JS via tsc --noEmit + eslint. iOS was not compiled in a full build here (no iOS build harness) — please let CI confirm.

login and switchTenant reported success on failure, and login errors were unobservable.

- Android: login ignored the callback's Exception? and always resolved ""; switchTenant ignored
  the SDK callback's Boolean and always resolved the tenant id. Route both through extracted,
  unit-tested helpers resolveOrRejectLogin(error, promise) / resolveTenantSwitch(success,
  tenantId, promise) that reject on failure.
- iOS: login resolved the string "Failed: …" instead of rejecting; switchTenant ignored the
  completion result. Both now reject with the FronteggError on failure (rejecter made @escaping).
- JS: login() was fire-and-forget (result swallowed in console.log). It now returns the promise so
  callers can await it and observe rejections.

Test: AuthResultPropagationTest (Android, RED->GREEN). iOS/JS verified via swiftc -parse, tsc
--noEmit and eslint.
@dianaKhortiuk-frontegg

Copy link
Copy Markdown
Collaborator Author

Superseded by #100, which combines FR-25937/38/39/40 into a single PR. Branch kept.

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