1

I have developed an App that uses Firebase. The user has to go through a Wordpress website and buy a subscription before being able to access the App. When a new Wordpress user registers, I would like to create the user in Firebase too with the very same credentials (e-mail/password). I have searched but not found anything to be able to do that. What would be the best solution. Thank you in advance!

1
  • Has there been any resolution to this? I'm in a very similar situation, searching for the same functionality. Thanks! May 23 '19 at 13:03
1

I have no knowledge or experience with Firebase specifically, so I will answer generally as it could be applicable to any external App / User Database synchronization.

The password is the tricky part, as WordPress hashes the password before putting it in the database, and so does not by default store the plain text password anywhere for security reasons. This means you would have to either:

  1. Send the username and password to the App API for storage upon user creation. Then activate those users later when they pay for subscription. However, this may mean you end up with a lot of inactive users in your App (who didn't buy a subscription after signup) which you would probably have to clean up (expire) regularly.

OR

  1. Save the plain text password to user meta upon user creation. Normally this would not be recommended, but if "anyone can register" for a WordPress subscriber account, which you are using to make a "real" membership later, then it's not really much of a security hole - as the free subscriber role has no extra privileges anyway. Then when they make a paid subscription, you can send the stored password to the App API with their membership and make sure to delete it from the user meta.

In either case, you would also need to add some code to synchronize a new password with via the App API in the case that the user changes it through their profile page.

4
  • Thank you for taking the time to type that reply. I was hoping there would be a plug-in hidden somewhere that would allow that more easily. or a solution not too complex to implement. I tried Zapier but I'm not sure it can be of any help. I'm still trying to understand how Webhooks work. I don't know if that would be a right direction tho.
    – Mike
    Mar 29 '19 at 13:07
  • a quick search turned up this one: wordpress.org/plugins/integrate-firebase which allows users to authenticate login via their Firebase account. I'm not sure if that is helpful in what you are wanting to achieve or not.
    – majick
    Mar 29 '19 at 14:53
  • Yes indeed, I would need the exact opposite ^^ something that also deals with users changing their password. Both wordpress and Firebase users credentials would have to be synced. I really thought this would be easier and people would have done it before with plugins.
    – Mike
    Mar 29 '19 at 15:09
  • 1
    It is just you have the opposite user on-boarding models from the start.As I said that was a quick search, it's still quite possible someone has done it your way around before and written a tutorial about it already, you probably should spend some time searching for that before proceeding in case you luck on it, but in any case to get an idea of how complex it might be. I could do this with custom code as have done similar before, but API integrations like this can be time-consuming and so not cheap to build or maintain (due to possible API changes.)
    – majick
    Mar 30 '19 at 1:24
0

The way you are thinking about it is to use two different identity providers (IdP), Firebase and WordPress, and keep them in sync. This is the most difficult solution to your problem. You really only want to have a single IdP and then use federation to allow users to log into another platform by using that single IdP.

In your scenario you want WordPress to be your IdP and Firebase to use federated IDs. FirebaseUI can be used to allow your application to use federated IDs. It supports both SAML and OpenID Connect which are two different ways you can authenticate your users to an IdP. Now you need a way for WordPress to be able to receive and respond to these requests. You'll be looking for a plugin like this one from miniOrange that has been made to allow you to use WordPress as an IdP and supports federation through SAML or OpenID Connect.

Using both FirebaseUI and a WordPress plugin you can now authenticate all your users to a single account and no longer have to worry about keeping two different login methods in sync.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.