Description
After getting a database reference and deleting the associated app, Firebase will always return the same instance to the initial database for an app's lifecycle.
The issue lies within FIRDatabase
: https://github.com/firebase/firebase-ios-sdk/blob/master/Firebase/Database/Api/FIRDatabase.m#L122.
The instances
array will hold an outdated reference of the database. The outdated database can point to a then deleted FIRApp
. Perhaps when a FIRApp
is deleted, any databases it owns should be removed from the instances
array.
- Xcode version: Version 8.3.3 (8E3004b)
- Firebase SDK version: 4.0.4
- Library version: 4.0.0
- Firebase Product: database
Steps to reproduce:
1.) Create a Firebase app with a specific name.
2.) Authenticate against the app.
3.) Get a Firebase database reference.
4.) Sign out.
5.) Delete the Firebase app.
6.) Create a Firebase app using the same name used in step 1.
7.) Authenticate against the Firebase app created in step 6.
8.) Get a Firebase database reference with databaseForApp:
using the app created in step 6.
The final Firebase database reference's app will actually point to the app created in step 1. This causes the database's authentication chain to break. Since the user is authenticated with the app created in step 6, the user will not be able to use the database.