1

In our project, we have several different apps that are using the same set of users that we authenticate using firebase (roles & privileges are stored and managed in our own server depending on the app they have been registerd for, firebase is only used to authenticate users).

Imagine e.g. an Uber-like setup with a driver and a passenger application.

We want our users to register inside these apps and receive an email verification link created by our server (using an external SMPT service for actually sending the email).

If a user clicks on an email verification link, they should be redirected right back into the respective android/iOS app. For that reason, we need to create our verification links with two different base urls like this:

  • passenger.myapp.com/welcome?mode=verifyEmail&oobCode=xxx&continueUrl=https%3A%2F%2Fpassenger.myapp.com&lang=de
  • driver.myapp.com/welcome?mode=verifyEmail&oobCode=xxx&continueUrl=https%3A%2F%2Fdriver.myapp.com&lang=de

So far, we have been unable to create links like these using only the firebase admin sdk. We tried creating the links somewhat like this:

EmailAddress email = new EmailAddress(Faker.instance().internet().safeEmailAddress())
// create account using email + password
// ...
ActionCodeSettings settings = ActionCodeSettings.builder()
    .setUrl("https://passenger.myapp.com")
    .setHandleCodeInApp(true)
    .build();
String verifyEmailLink = FirebaseAuth.getInstance().generateEmailVerificationLink(email.getValue(), settings);

Our main issue is that firebase only uses localhost:3100/welcome as the base url to create those links (not passenger.myapp.com). This seems to be happening because we added localhost:3100/welcome as the default action url in the firebase console:

enter image description here

Can we somehow change the action url when creating the link using the firebase admin sdk depending on what app (passenger vs driver) the registration has happened in?

As a workaround, we currently work with a simple string-replace after creating these links, but I was wondering if there is a better way or if this might lead to problems that we are just not aware of yet:

verifyEmailLink = verifyEmailLink.replace("http://localhost:3100/welcome", "https://passenger.myapp.com/welcome");
Florian Baierl
  • 2,378
  • 3
  • 25
  • 50

0 Answers0