Skip to content

@W-19345684: [iOS][QRCode] Shows Unsupported URL on FreshLogin using QRCode - #3901

Merged
JohnsonEricAtSalesforce merged 2 commits into
forcedotcom:devfrom
JohnsonEricAtSalesforce:bugfix/w-19345684_ios_qrcode-shows-unsupported-url-on-freshlogin-using-qrcode
Aug 22, 2025
Merged

JohnsonEricAtSalesforce merged 2 commits into
forcedotcom:devfrom
JohnsonEricAtSalesforce:bugfix/w-19345684_ios_qrcode-shows-unsupported-url-on-freshlogin-using-qrcode

Conversation

@JohnsonEricAtSalesforce

Copy link
Copy Markdown
Contributor

🥁 Ready For Review 🎸

This simple fix makes the iOS side of QR Code Log In override the user-agent or web server flows just as Android now does. The error in the video was caused by the web server flow oriented QR code getting handled like a user agent one.

@codecov

codecov Bot commented Aug 19, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.28%. Comparing base (6b9abc9) to head (0a1093f).
⚠️ Report is 3 commits behind head on dev.

Files with missing lines Patch % Lines
...lesforceSDKCore/Classes/OAuth/SFOAuthCoordinator.m 0.00% 4 Missing ⚠️

❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #3901      +/-   ##
==========================================
+ Coverage   63.06%   63.28%   +0.22%     
==========================================
  Files         251      251              
  Lines       22467    22469       +2     
==========================================
+ Hits        14168    14220      +52     
+ Misses       8299     8249      -50     
Components Coverage Δ
Analytics 70.78% <ø> (ø)
Common 70.58% <ø> (ø)
Core 53.58% <0.00%> (+0.36%) ⬆️
SmartStore 73.66% <ø> (ø)
MobileSync 87.66% <ø> (ø)
Files with missing lines Coverage Δ
...lesforceSDKCore/Classes/OAuth/SFOAuthCoordinator.m 42.23% <0.00%> (+0.17%) ⬆️

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

BOOL isUsingWebServerAuthentication = [[SalesforceSDKManager sharedManager] useWebServerAuthentication];
// Second, switch authentication based on the in-use Salesforce Identity API UI Bridge front-door URL and code verifier.
if (self.frontdoorBridgeLoginOverride.frontdoorBridgeUrl) {
isUsingWebServerAuthentication = self.frontdoorBridgeLoginOverride.codeVerifier;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

codeVerifier isn't a BOOL? The previous !self.frontdoorBridgeLoginOverride.codeVerifier call just checked if it was nil.

So if self.frontdoorBridgeLoginOverride.codeVerifier assigned to a BOOL just checks if it's nil what is the change in logic here? It looks the same to me.

@JohnsonEricAtSalesforce JohnsonEricAtSalesforce Aug 19, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since this is Obj-C, any pointer value (for a string in this case) can scale as a BOOL. nil = NO and any value = YES.

The key difference is that the non-nil (YES) value for the object in frontdoorBridgeLoginOverride.frontdoorBridgeUrl is checked first. That prevents the case I was seeing in the app at runtime where setting useWebServerAuthentication = NO would accidentally force user-agent handling for web-server-flow QR log in URLs. We vetted really similar logic in the Android app and this also works live in the iOS app as well, so we have those results to guide the runtime review.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would it be more readable with

// If frontdoorBridgeUrl is present, use codeVerifier to decide; otherwise, fall back to useWebServerAuthentication
if (self.frontdoorBridgeLoginOverride.frontdoorBridgeUrl  // Check if an override is provided
        ? self.frontdoorBridgeLoginOverride.codeVerifier   // If yes, only proceed if it's a web server flow (has codeVerifier)
        : [[SalesforceSDKManager sharedManager] useWebServerAuthentication]  // If no override, use default SDK setting
    ) 
{
    [self handleWebServerResponse:url]; // Web server flow/URLs with query string parameters.
} else {
    [self handleUserAgentResponse:url]; // User agent flow/URLs with the fragment component.
}

@JohnsonEricAtSalesforce JohnsonEricAtSalesforce Aug 21, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That wouldn't compile, but this slight change will. Note the ternary operator needs both results to be of the same type, so it can't scale the Int as a BOOL like the previous version did or the compiler produces:

Incompatible operand types ('NSString * _Nullable' and 'int')

if (self.frontdoorBridgeLoginOverride.frontdoorBridgeUrl  // Check if an override is provided
            ? self.frontdoorBridgeLoginOverride.codeVerifier != nil   // If yes, only proceed if it's a web server flow (has codeVerifier)
            : [[SalesforceSDKManager sharedManager] useWebServerAuthentication]  // If no override, use default SDK setting
            )
        {
            [self handleWebServerResponse:url]; // Web server flow/URLs with query string parameters.
        } else {
            [self handleUserAgentResponse:url]; // User agent flow/URLs with the fragment component.
        }

@JohnsonEricAtSalesforce JohnsonEricAtSalesforce Aug 21, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I do like the syntax candy, but I found this version just a little harder to process just from the code since it's more terse. It works though, so I tried massaging the comments a bit to see if that helped get the best of it all. Take a look at this 👉🏻 8141639

@JohnsonEricAtSalesforce
JohnsonEricAtSalesforce merged commit 1add4ee into forcedotcom:dev Aug 22, 2025
3 of 5 checks passed
@JohnsonEricAtSalesforce
JohnsonEricAtSalesforce deleted the bugfix/w-19345684_ios_qrcode-shows-unsupported-url-on-freshlogin-using-qrcode branch August 22, 2025 22:21
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.

4 participants