Skip to content

Add Login for Admin feature#2870

Merged
brandonpage merged 2 commits intoforcedotcom:devfrom
brandonpage:login-for-admin
Apr 23, 2026
Merged

Add Login for Admin feature#2870
brandonpage merged 2 commits intoforcedotcom:devfrom
brandonpage:login-for-admin

Conversation

@brandonpage
Copy link
Copy Markdown
Contributor

The Android implementation of this feature is quite a bit more involved and far reaching than its iOS counterpart. I choose to do a mini re-write of how the LoginViewModel handles generating urls because:

  • loginUrl, browserCustomTabUrl, the authorization url used for token migration and the authorization url used for front door bridge were all created from a single function that retuned a single url. With the Web Server flow, running that function a second time generates a new code verifier and will break login using any previously generated url. I foresee future scenarios where this becomes very problematic if we are starting and cancelling/switching different auth flows.
  • With BrowserCustomTabUrlSource it was possible to generate an authorization url for singleServerCustomTabActivity that did not use the Web Server Flow, which should never be allowed.
  • Adding another boolean flag (like I did on iOS) doubles the matrix of test scenarios and makes the code harder to follow. This PR aims to do the opposite, removing several instances of if (!sdkManager.isBrowserLoginEnabled && !singleServerCustomTabActivity && !viewModel.isUsingFrontDoorBridge ... .

To address the above issues, this PR:

  • Changes getAuthorizationUrl to generateAuthorizationUrl (maybe it should be plural?), which sets both loginUrl and browserCustomTabUrl and returns nothing.
  • Add a generateMigrationAuthorizationPath function to handle Token Migration Authorization Url generation separately.
  • Add a separate frontDoorBridgeUrl variable so loginUrl never needs to be re-generated to avoid using Web Server.
  • Add a new (very simple) onBrowserCustomTabReady launching mechanism.

Demo of cancelling 'Login for Admin' vs org triggered Advanced Auth:

login_for_admin_cancel.mp4

@github-actions
Copy link
Copy Markdown

1 Warning
⚠️ Big PR, try to keep changes smaller if you can.

Generated by 🚫 Danger

Copy link
Copy Markdown
Contributor

@JohnsonEricAtSalesforce JohnsonEricAtSalesforce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

❌ Patch coverage is 83.05085% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.89%. Comparing base (5122b1b) to head (3df1c5a).
⚠️ Report is 3 commits behind head on dev.

Files with missing lines Patch % Lines
...src/com/salesforce/androidsdk/ui/LoginViewModel.kt 85.71% 4 Missing and 8 partials ⚠️
.../src/com/salesforce/androidsdk/ui/LoginActivity.kt 78.94% 0 Missing and 4 partials ⚠️
...m/salesforce/androidsdk/ui/components/LoginView.kt 71.42% 1 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                dev    #2870      +/-   ##
============================================
- Coverage     64.90%   64.89%   -0.02%     
- Complexity     2974     2979       +5     
============================================
  Files           222      222              
  Lines         17449    17489      +40     
  Branches       2489     2496       +7     
============================================
+ Hits          11325    11349      +24     
- Misses         4920     4926       +6     
- Partials       1204     1214      +10     
Components Coverage Δ
Analytics 47.92% <ø> (ø)
SalesforceSDK 59.83% <83.05%> (+<0.01%) ⬆️
Hybrid 59.05% <ø> (ø)
SmartStore 78.20% <ø> (ø)
MobileSync 81.68% <ø> (ø)
React 51.50% <ø> (ø)
Files with missing lines Coverage Δ
...salesforce/androidsdk/ui/TokenMigrationActivity.kt 83.60% <100.00%> (-0.14%) ⬇️
.../src/com/salesforce/androidsdk/ui/LoginActivity.kt 43.67% <78.94%> (-1.54%) ⬇️
...m/salesforce/androidsdk/ui/components/LoginView.kt 44.70% <71.42%> (+0.99%) ⬆️
...src/com/salesforce/androidsdk/ui/LoginViewModel.kt 87.91% <85.71%> (-0.71%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@brandonpage brandonpage merged commit addf159 into forcedotcom:dev Apr 23, 2026
20 checks passed
brandonpage added a commit that referenced this pull request Apr 25, 2026
* Add Login for Admin feature and fix existing issues with browser url and custom tabs routing. (#2870)

* Fix Login for Admin string. (#2873)
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.

2 participants