Skip to content

[🐛] [🔥] sendPasswordResetEmail - auth/internal-error when url included / linkDomain param behaving unexpectedly #6838

Open
@mbaker3

Description

@mbaker3

Issue

Currently having issues sending a password reset email when the continue URL is included. When a whitelisted URL is included in the actionCodeSettings object firebase returns an auth/internal-error. I haven't yet tried setting up dynamic links to see if the continue URL will work with a dynamic link vs a standard (whitelisted) url.

I'm hoping to be able to redirect to one of our own web pages once password reset is complete. I don't believe setting up dynamic links should be required but feel free to dismiss this bug if I've misinterpreted what firebase should support!

(This is in an Expo project using the custom dev client)

My usage is as follows

import auth, { FirebaseAuthTypes } from "@react-native-firebase/auth";
import * as Application from "expo-application";
// ...
auth()
   .sendPasswordResetEmail(email, {
      url: "https://my.whitelisted.url.com",
      handleCodeInApp: false,
      iOS: { bundleId: Application.applicationId! },
      android: {
        packageName: Application.applicationId!,
       installApp: true,
      },
    })
   .then(()=>console.log("success"))
   .catch((error) => console.error(error))

The error emitted:
[auth/internal-error] An internal error has occurred, please try again.


Project Files

Javascript

Click To Expand

package.json:

{
  "scripts": {
    "start": "npx expo start --dev-client",
    "prebuild-ios": "npx expo prebuild -p ios --clean",
    "local-build-ios": "eas build --platform ios --local --profile debug-simulator",
    "remote-build-debug-sim": "eas build --platform ios --profile debug-simulator",
    "remote-build-debug": "eas build --platform ios --profile debug",
    "remote-build-stage": "eas build --platform ios --profile stage",
    "remote-build-beta": "eas build --platform ios --profile beta",
    "publish-debug": "eas update --branch debug --message",
    "publish-stage": "expo publish --release-channel stage",
    "publish-beta": "expo publish --release-channel beta",
    "android": "npx expo run:android",
    "ios": "npx expo run:ios"
  },
  "dependencies": {
    "@logrocket/react-native": "^1.5.0",
    "@react-native-async-storage/async-storage": "~1.17.3",
    "@react-native-firebase/app": "^16.4.3",
    "@react-native-firebase/auth": "^16.4.3",
    "@react-native-firebase/crashlytics": "^16.4.3",
    "@react-native-firebase/firestore": "^16.4.3",
    "@react-native-firebase/functions": "^16.4.3",
    "@react-native-firebase/perf": "^16.4.3",
    "@react-native-google-signin/google-signin": "8.0.0",
    "@react-navigation/bottom-tabs": "^6.3.3",
    "@react-navigation/native": "^6.0.12",
    "@react-navigation/stack": "^6.2.3",
    "@types/lodash": "^4.14.185",
    "dayjs": "^1.11.5",
    "expo": "~46.0.19",
    "expo-app-loading": "~2.1.0",
    "expo-apple-authentication": "~4.3.0",
    "expo-build-properties": "~0.3.0",
    "expo-clipboard": "~3.1.0",
    "expo-dev-client": "~1.3.1",
    "expo-device": "~4.3.0",
    "expo-font": "~10.2.0",
    "expo-linking": "~3.2.4",
    "expo-splash-screen": "~0.16.2",
    "expo-status-bar": "~1.4.0",
    "expo-updates": "~0.14.7",
    "react": "18.0.0",
    "react-dom": "18.0.0",
    "react-native": "0.69.6",
    "react-native-date-picker": "^4.2.5",
    "react-native-gesture-handler": "~2.5.0",
    "react-native-reanimated": "~2.9.1",
    "react-native-safe-area-context": "4.3.1",
    "react-native-screens": "~3.15.0",
    "react-native-svg": "12.3.0",
    "react-native-uuid": "^2.0.1",
    "react-native-web": "~0.18.7",
    "system-ui": "^1.0.0"
  },
  "devDependencies": {
    "@babel/core": "^7.18.6",
    "@babel/plugin-proposal-logical-assignment-operators": "^7.18.9",
    "@types/react": "~18.0.0",
    "@types/react-native": "~0.69.1",
    "@typescript-eslint/eslint-plugin": "^5.38.0",
    "@typescript-eslint/parser": "^5.38.0",
    "eslint": "^8.23.1",
    "eslint-config-universe": "^11.1.0",
    "eslint-plugin-react-hooks": "^4.6.0",
    "prettier": "^2.7.1",
    "react-native-svg-transformer": "^1.0.0",
    "typescript": "^4.6.3"
  },
  "resolutions": {
    "@logrocket/react-native/@expo/config-plugins": "^5.0.0"
  },
  "eslintConfig": {
    "extends": [
      "universe/native",
      "plugin:react-hooks/recommended"
    ],
    "rules": {
      "object-shorthand": "off",
      "react/jsx-boolean-value": "off"
    }
  },
  "private": true,
  "name": "some-app",
  "version": "1.0.0"
}

firebase.json for react-native-firebase v6:

# N/A

iOS

Click To Expand

ios/Podfile:

  • I'm not using Pods
  • I'm using Pods and my Podfile looks like:
require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")
require File.join(File.dirname(`node --print "require.resolve('@react-native-community/cli-platform-ios/package.json')"`), "native_modules")

require 'json'
podfile_properties = JSON.parse(File.read(File.join(__dir__, 'Podfile.properties.json'))) rescue {}

platform :ios, podfile_properties['ios.deploymentTarget'] || '12.4'
install! 'cocoapods',
  :deterministic_uuids => false

target 'SomeApp' do
  use_expo_modules!
  config = use_native_modules!

  use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']

  # Flags change depending on the env values.
  flags = get_default_flags()

  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => flags[:hermes_enabled] || podfile_properties['expo.jsEngine'] == 'hermes',
    :fabric_enabled => flags[:fabric_enabled],
    # An absolute path to your application root.
    :app_path => "#{Dir.pwd}/.."
  )

  # Uncomment to opt-in to using Flipper
  # Note that if you have use_frameworks! enabled, Flipper will not work
  #
  # if !ENV['CI']
  #   use_flipper!()
  # end

  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)

    # This is necessary for Xcode 14, because it signs resource bundles by default
    # when building for devices.
    installer.target_installation_results.pod_target_installation_results
      .each do |pod_name, target_installation_result|
      target_installation_result.resource_bundle_targets.each do |resource_bundle_target|
        resource_bundle_target.build_configurations.each do |config|
          config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
        end
      end
    end
  end

  post_integrate do |installer|
    begin
      expo_patch_react_imports!(installer)
    rescue => e
      Pod::UI.warn e
    end
  end
end

AppDelegate.m:

#import "AppDelegate.h"
// AUTO GENERATED START - DO NOT EDIT: Auto generated at build time by: withLocalNotification

#import <UserNotifications/UserNotifications.h>
#import "LocalNotification.h"
// AUTO GENRATED END - withLocalNotification
#import <Firebase/Firebase.h>

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <React/RCTLinkingManager.h>
#import <React/RCTConvert.h>

#import <React/RCTAppSetupUtils.h>

#if RCT_NEW_ARCH_ENABLED
#import <React/CoreModulesPlugins.h>
#import <React/RCTCxxBridgeDelegate.h>
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
#import <React/RCTSurfacePresenter.h>
#import <React/RCTSurfacePresenterBridgeAdapter.h>
#import <ReactCommon/RCTTurboModuleManager.h>

#import <react/config/ReactNativeConfig.h>

static NSString *const kRNConcurrentRoot = @"concurrentRoot";

@interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> {
  RCTTurboModuleManager *_turboModuleManager;
  RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
  std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig;
  facebook::react::ContextContainer::Shared _contextContainer;
}
@end
#endif

@implementation AppDelegate
// AUTO GENERATED START - DO NOT EDIT: Auto generated at build time by: withLocalNotification
{
  UserNotificationDelegate *_notificationDelegate;
}
// AUTO GENRATED END - withLocalNotification

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// AUTO GENERATED START - DO NOT EDIT: Auto generated at build time by: withLocalNotification
  _notificationDelegate = [[UserNotificationDelegate alloc] init];
  [UNUserNotificationCenter currentNotificationCenter].delegate = _notificationDelegate;

// AUTO GENRATED END - withLocalNotification
  RCTAppSetupPrepareApp(application);

// @generated begin @react-native-firebase/app-didFinishLaunchingWithOptions - expo prebuild (DO NOT MODIFY) sync-ecd111c37e49fdd1ed6354203cd6b1e2a38cccda
[FIRApp configure];
// @generated end @react-native-firebase/app-didFinishLaunchingWithOptions
  RCTBridge *bridge = [self.reactDelegate createBridgeWithDelegate:self launchOptions:launchOptions];

#if RCT_NEW_ARCH_ENABLED
  _contextContainer = std::make_shared<facebook::react::ContextContainer const>();
  _reactNativeConfig = std::make_shared<facebook::react::EmptyReactNativeConfig const>();
  _contextContainer->insert("ReactNativeConfig", _reactNativeConfig);
  _bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer];
  bridge.surfacePresenter = _bridgeAdapter.surfacePresenter;
#endif

  NSDictionary *initProps = [self prepareInitialProps];
  UIView *rootView = [self.reactDelegate createRootViewWithBridge:bridge moduleName:@"main" initialProperties:initProps];

  rootView.backgroundColor = [UIColor whiteColor];
  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [self.reactDelegate createRootViewController];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];

  [super application:application didFinishLaunchingWithOptions:launchOptions];

  return YES;
}

- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge
{
  // If you'd like to export some custom RCTBridgeModules, add them here!
  return @[];
}

/// This method controls whether the `concurrentRoot`feature of React18 is turned on or off.
///
/// @see: https://reactjs.org/blog/2022/03/29/react-v18.html
/// @note: This requires to be rendering on Fabric (i.e. on the New Architecture).
/// @return: `true` if the `concurrentRoot` feture is enabled. Otherwise, it returns `false`.
- (BOOL)concurrentRootEnabled
{
  // Switch this bool to turn on and off the concurrent root
  return true;
}

- (NSDictionary *)prepareInitialProps
{
  NSMutableDictionary *initProps = [NSMutableDictionary new];
#if RCT_NEW_ARCH_ENABLED
  initProps[kRNConcurrentRoot] = @([self concurrentRootEnabled]);
#endif
  return initProps;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

// Linking API
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
  return [super application:application openURL:url options:options] || [RCTLinkingManager application:application openURL:url options:options];
}

// Universal Links
- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
  BOOL result = [RCTLinkingManager application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
  return [super application:application continueUserActivity:userActivity restorationHandler:restorationHandler] || result;
}

// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
  return [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}

// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
  return [super application:application didFailToRegisterForRemoteNotificationsWithError:error];
}

// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
  return [super application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}

#if RCT_NEW_ARCH_ENABLED

#pragma mark - RCTCxxBridgeDelegate

- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
{
  _turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge
                                                             delegate:self
                                                            jsInvoker:bridge.jsCallInvoker];
  return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager);
}

#pragma mark RCTTurboModuleManagerDelegate

- (Class)getModuleClassFromName:(const char *)name
{
  return RCTCoreModulesClassProvider(name);
}

- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
                                                      jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
{
  return nullptr;
}

- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
                                                     initParams:
                                                         (const facebook::react::ObjCTurboModule::InitParams &)params
{
  return nullptr;
}

- (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
{
  return RCTAppSetupDefaultModuleFromClass(moduleClass);
}

#endif

@end


Android

Not currently targeting with app.

Click To Expand

Have you converted to AndroidX?

  • my application is an AndroidX application?
  • I am using android/gradle.settings jetifier=true for Android compatibility?
  • I am using the NPM package jetifier for react-native compatibility?

android/build.gradle:

// N/A

android/app/build.gradle:

// N/A

android/settings.gradle:

// N/A

MainApplication.java:

// N/A

AndroidManifest.xml:

<!-- N/A -->


Environment

Click To Expand

react-native info output:

info Fetching system and libraries information...
System:
    OS: macOS 13.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 170.20 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.13.0 - /var/folders/bh/46mx29x52bd3lxp94d1l0w1m0000gn/T/yarn--1673930127780-0.9800396747328977/node
    Yarn: 1.22.19 - /var/folders/bh/46mx29x52bd3lxp94d1l0w1m0000gn/T/yarn--1673930127780-0.9800396747328977/yarn
    npm: 8.19.1 - /usr/local/bin/npm
    Watchman: 2022.07.04.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
    Android SDK:
      API Levels: 31
      Build Tools: 31.0.0, 32.0.0
      System Images: android-25 | Google APIs ARM EABI v7a, android-31 | Google APIs ARM 64 v8a
      Android NDK: Not Found
  IDEs:
    Android Studio: 2021.1 AI-211.7628.21.2111.8309675
    Xcode: 14.2/14C18 - /usr/bin/xcodebuild
  Languages:
    Java: Not Found
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.0.0 => 18.0.0 
    react-native: 0.69.6 => 0.69.6 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
info React Native v0.71.0 is now available (your project is running on v0.69.6).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.71.0.
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.69.6.
info To upgrade, run "react-native upgrade".
  • Platform that you're experiencing the issue on:
    • iOS
    • Android
    • iOS but have not tested behavior on Android
    • Android but have not tested behavior on iOS
    • Both
  • react-native-firebase version you're using that has this issue:
    • 16.4.3
    • 16.5.0
  • Firebase module(s) you're using that has the issue:
    • auth
  • Are you using TypeScript?
    • Y & 4.8.3
  • Expo verssion:
    • 46.0.19


Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions