fix(react-native): propagate login and switchTenant failures (FR-25938) - #95
Closed
dianaKhortiuk-frontegg wants to merge 1 commit into
Closed
Conversation
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.
Collaborator
Author
|
Superseded by #100, which combines FR-25937/38/39/40 into a single PR. Branch kept. |
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-25938 — login/switchTenant report success on failure; login errors unobservable
login's callback ignored theException?and always resolved"";switchTenantignored the SDK callback'sBooleanand always resolved the tenant id. Both now go through extracted, unit-tested helpersresolveOrRejectLogin(error, promise)/resolveTenantSwitch(success, tenantId, promise)that reject on failure.loginresolved the string"Failed: …"instead of rejecting;switchTenantignored the completion result and always resolved. Both nowreject(...)with theFronteggErroron failure (rejectermade@escapingsince the completion escapes).login()was fire-and-forget (result swallowed inconsole.log). It nowreturns the promise so callers canawaitit 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_ERRORreject; switchTenant true → resolve tenant id, false →SWITCH_TENANT_ERRORreject. RED → GREEN via the example-app Gradle harness.Note
iOS Swift verified via
swiftc -parse; JS viatsc --noEmit+ eslint. iOS was not compiled in a full build here (no iOS build harness) — please let CI confirm.