Skip to content

ActionCodeOperation mapping fails due to incorrect requestType casing in ActionCodeInfo #14665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
stefangerard opened this issue Apr 6, 2025 · 2 comments
Assignees

Comments

@stefangerard
Copy link

Description

In FirebaseAuth/Sources/Swift/ActionCode/ActionCodeInfo.swift, the method actionCodeOperation(forRequestType:) uses all-uppercase string literals (e.g. "PASSWORD_RESET", "VERIFY_EMAIL") to match against the request type string received from the server.

However, Firebase uses camelCase for the mode parameter in action links, as documented here:
https://firebase.google.com/docs/auth/custom-email-handler#create_the_email_action_handler_page

Because of this mismatch, the method always returns .unknown.

Code Reference

https://github.com/firebase/firebase-ios-sdk/blob/HEAD/FirebaseAuth/Sources/Swift/ActionCode/ActionCodeInfo.swift#L43-L53

class func actionCodeOperation(forRequestType requestType: String?) -> ActionCodeOperation {
  switch requestType {
  case "PASSWORD_RESET": return .passwordReset
  case "VERIFY_EMAIL": return .verifyEmail
  case "RECOVER_EMAIL": return .recoverEmail
  case "EMAIL_SIGNIN": return .emailLink
  case "VERIFY_AND_CHANGE_EMAIL": return .verifyAndChangeEmail
  case "REVERT_SECOND_FACTOR_ADDITION": return .revertSecondFactorAddition
  default: return .unknown
  }
}

Suggested Fix

Update the switch statement to use camelCase keys to match the values provided by Firebase in the mode parameter.

switch requestType {
case "resetPassword": return .passwordReset
case "verifyEmail": return .verifyEmail
case "recoverEmail": return .recoverEmail
case "signIn": return .emailLink
case "verifyAndChangeEmail": return .verifyAndChangeEmail
case "revertSecondFactorAddition": return .revertSecondFactorAddition
default: return .unknown
}

Reproducing the issue

  1. Trigger any Firebase action that sends an email with an action link (e.g., password reset).
  2. Open the link and inspect the mode parameter – it will be camelCase (e.g., mode=resetPassword).
  3. When passed to ActionCodeURL, the internal mapping in ActionCodeInfo returns .unknown.

Expected behavior:
ActionCodeOperation should correctly reflect the action specified in the mode parameter.

Actual behavior:
ActionCodeOperation == .unknown

Firebase SDK Version

11.11.0

Xcode Version

16.3

Installation Method

Swift Package Manager

Firebase Product(s)

Authentication

Targeted Platforms

All

Relevant Log Output

If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet
Replace this line with the contents of your Package.resolved.

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet
Replace this line with the contents of your Podfile.lock!
@google-oss-bot
Copy link

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@rizafran
Copy link
Contributor

Thanks for the report, @stefangerard. The fix has been merged and will be included in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants