Skip to content

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

Closed
@stefangerard

Description

@stefangerard

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

classfunc 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!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    close