'I'm trying to link between Firebase Authentication and MySQL using a new scenario

I want to take your opinion about this weird scenario before applying it.

I'm using FirebaseUI.

The users' table

ID NAME EMAIL PHONE_NUMBER PHOTO_URL CREATED SIGNED_IN WALLET_BALANCE ADDRESS ETC...
... ... ... ... ... ... ... ... ... ...

First I'll explain what I want to do

I want when an account of the user is added in FIAU (Firebase Authentication), Create another request with the server and add the user info inside the users' table in MySQL, If the request failed to add the user in MySQL then must delete the user from FIAU also.

I want when an account of the user is updated in FIAU, Create another request with the server and update the user info inside the users' table in MySQL, If the request failed to update the user in MySQL then must be reset the old user info before the update.

That is not possible with FIAU.

As you can see, Always the problem comes from the second request, If it failed then you can not roll back for the first operation.

Here are the current solutions that I know it

These solutions may be failed also.

Here is the scenario that I want to apply it

Sending a new request to add the user in FIAU
|
--- Successful result
    |
    --- Sending a new request to add the user in the users' table in MySQL
        |
        --- Successful result
            |
            --- ...
        --- Failing result
            |
            --- Error message and sign out the user from his account
                |
                --- In this step, I'll keep the user account in the FIAU even if the second request failed to add the user in MySQL.
--- Failing result
    |
    --- Error message

____________________________________

Sending a new request to update the user in FIAU
|
--- Successful result
    |
    --- Sending a new request to update the user info in the users' table in MySQL
        |
        --- Successful result
            |
            --- ...
        --- Failing result
            |
            --- Error message (Failed to update your info)
                |
                --- In this step, I'll keep the new info in the FIAU even if the second request failed to update the user info in MySQL.
--- Failing result
    |
    --- Error message

As you can see, The user data is different sometimes between FIAU and MySQL, And of course, You cannot solve the difference problem between FIAU and MySQL. So the radical solution for me is this:

When the user signs in using FIAU, I'll ignore the user data stored in FIAU and get the user data stored in MySQL.

I'll use FIAU for the login and register only and I don't care about the data inside it.

I'll get the user data from FIAU when the user is new only but after that, I don't care about the data inside FIAU.

I want to take your opinion on this scenario, Is it good to apply it because I can't find any alternative currently.

Also, I'm afraid to face unexpected problems in this scenario that will drive me to rebuild everything from scratch.

Your answer or comment means a lot to me, Thanks for your precious time ❤️️

I hope someday FIAU supports custom fields.



Solution 1:[1]

I applied this scenario and didn't find any problem until now

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 T38416