I have a problem with my app, when I signout() and I want to create a new user, I still have some of the data of the previous user.
The app was coded by another developer (i have no contact with him) so I tried to find the problem.
there is also another problem with I logOut, I have this error
Uncaught Error in snapshot listener: [FirebaseError: Missing or insufficient permissions.]
my function logout :
// my button logout
const onLogout = () => {
authManager.logout(currentUser);
//dispatch(logout());
props.navigation.navigate('LoadScreen', {
appStyles: DynamicAppStyles,
appConfig: DatingConfig,
});
setModalVisible(false);
};
const renderModalVisible = () => {
setModalVisible(true);
};
//then authmanager.logout()
const logout = (user) => {
console.log('deco');
const userData = {
...user,
isOnline: false,
};
authAPI.updateUser(user.id || user.userID, userData);
authAPI.logout();
};
//the authAPI.logout()
export const logout = () => {
firebase.auth().signOut();
RNFBAuth.auth().signOut();
};
it could also come from my persistent function but the process goes directly on the 'else'
const retrievePersistedAuthUser = () => {
console.log('persiste');
return new Promise((resolve) => {
authAPI.retrievePersistedAuthUser().then((user) => {
if (user) {
handleSuccessfulLogin(user, false).then((res) => {
// Persisted login successful, push token stored, login credential persisted, so we log the user in.
resolve({
user: res.user,
});
});
} else {
console.log('héééhoooooo');
resolve(null);
}
});
});
};