Skip to content

fix: 2FA code request error alert - WPB-24847#4609

Open
johnxnguyen wants to merge 7 commits intorelease/cycle-4.16from
fix/rate-limit-error-wpb-24847
Open

fix: 2FA code request error alert - WPB-24847#4609
johnxnguyen wants to merge 7 commits intorelease/cycle-4.16from
fix/rate-limit-error-wpb-24847

Conversation

@johnxnguyen
Copy link
Copy Markdown
Collaborator

@johnxnguyen johnxnguyen commented Apr 21, 2026

BugWPB-24847 [iOS] [Login] Error message is displayed after password entry during login by user

Issue

2FA codes from the backend can only be requested once within a time interval. If the code is requested multiple times in within the interval it will return a 429 "too many request" error.

This error is not handled in any particular way and is surfaced to the error as a generic "something went wrong" alert which confuses the user.

Simulator.Screen.Recording.-.A.-.2026-04-21.at.23.48.37.mov

This PR improves the error handling to better inform the user what is going on by:

  • telling them that a code has successfully been sent (when requested explicitly)
  • telling them that a code has already been sent (when being rate limited)
  • disabling the button to request a new code and showing the number of seconds until a new code can be requested
Simulator.Screen.Recording.-.A.-.2026-04-21.at.23.26.30.mov
Simulator.Screen.Recording.-.A.-.2026-04-21.at.23.31.29.mov

Testing

  • Enter email and password credentials for an account that requires 2FA
  • When asked to input the 2FA code, request a new code.
  • Assert the error alert is shown and the request code button is disabled.
  • assert that after the timeout a new code can be requested.

Checklist

  • Title contains a reference JIRA issue number like [WPB-XXX].
  • Description is filled and free of optional paragraphs.
  • Adds/updates automated tests.

UI accessibility checklist

If your PR includes UI changes, please utilize this checklist:

  • Make sure you use the API for UI elements that support large fonts.
  • All colors are taken from WireDesign.ColorTheme or constructed using WireDesign.BaseColorPalette.
  • New UI elements have Accessibility strings for VoiceOver.

@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 21, 2026

Test Results

    7 files    775 suites   6m 2s ⏱️
5 112 tests 5 084 ✅ 28 💤 0 ❌
5 113 runs  5 085 ✅ 28 💤 0 ❌

Results for commit 067dfea.

Summary: workflow run #24748763385
Allure report (download zip): html-report-29426-fix_rate-limit-error-wpb-24847

Copy link
Copy Markdown
Collaborator

@netbe netbe left a comment

Choose a reason for hiding this comment

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

lgtm:) left a few comments

Comment on lines +75 to +80
if viewModel.retryAfterSeconds > 0 {
Text(Strings.VerificationCode.resendCodeAfterSeconds(viewModel.retryAfterSeconds))
.monospacedDigit()
} else {
Text(Strings.VerificationCode.resendCode)
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggestion: move if else inside viewModel

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Do you mean to just have something like Text(viewModel.resendButtonTitle)?

Comment on lines +212 to +213
let retryAfter = responseHeaders["retry-after"].flatMap { TimeInterval($0) }
throw AuthenticationAPIError.tooManyRequests(error.message, retyAfter: retryAfter)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

thought: I wonder if this information could be a security concern

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The information that there is a rate limit? Or the number seconds until the limit is removed?

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.

3 participants