ionic5-firebase-authentication icon indicating copy to clipboard operation
ionic5-firebase-authentication copied to clipboard

Authentication service is not working with the latest version of the Firebase

Open marcalbet opened this issue 4 years ago • 11 comments

Hi,

The authentication service is not working with the current version of Firebase:

package.json file

"dependencies": {
    "@angular/fire": "^6.1.4",
    "firebase": "^8.2.7",
  },

I've changed the wrong imports but it is still failing in the execution time:

firebase-auth.service.ts file

//import { User, auth } from 'firebase/app';
import {User} from '@firebase/auth-types';
import auth from 'firebase/firebase-auth'; 

Regards.

marcalbet avatar Feb 17 '21 10:02 marcalbet

If I come back to your Firebase version then it's works but it could be interesting to fix it. ;)

1 - npm uninstall firebase @angular/fire 2 - delete package-lock.json file 3 - npm install [email protected] @angular/[email protected] --save

package.json file

"dependencies": {
    "@angular/fire": "^6.0.3",
    "firebase": "^7.24.0",
  },

Regards.

marcalbet avatar Feb 17 '21 10:02 marcalbet

What error message are you getting?

djabif avatar Feb 17 '21 10:02 djabif

If I use these dependencies:

package.json file

"dependencies": {
    "@angular/fire": "^6.1.4",
    "firebase": "^8.2.7",
  },

directly I can't compile with this import:

firebase-auth.service.ts file

import { User, auth } from 'firebase/app';

User and auth are not recognized.

marcalbet avatar Feb 17 '21 10:02 marcalbet

Is this your issue? https://github.com/angular/angularfire/issues/2619

djabif avatar Feb 17 '21 13:02 djabif

Yes!

ERROR in node_modules/@angular/fire/auth/auth.d.ts:4:10 - error TS2614: Module '"../../../firebase"' has no exported member 'User'. Did you mean to use 'import User from "../../../firebase"' instead?
4 import { User, auth } from 'firebase/app';
           ~~~~
node_modules/@angular/fire/auth/auth.d.ts:4:16 - error TS2614: Module '"../../../firebase"' has no exported member 'auth'. Did you mean to use 'import auth from "../../../firebase"' instead?
4 import { User, auth } from 'firebase/app';

marcalbet avatar Feb 17 '21 14:02 marcalbet

OK. I will try to update it for the next release of the template. Meanwhile, can you use the versions from the package.json?

"dependencies": {
    "@angular/fire": "^6.0.3",
    "firebase": "^7.24.0",
  },

djabif avatar Feb 17 '21 17:02 djabif

Yes. Thank you for your support. ;)

Regards.

marcalbet avatar Feb 17 '21 20:02 marcalbet

import { User, auth } from 'firebase/app';

I am no expert here but I believe the code needs to be modified thusly: import { User, auth } from 'firebase';

https://firebase.google.com/docs/reference/js/firebase.User

BetterAutomations avatar Jun 18 '21 12:06 BetterAutomations

@BetterAutomations , That is for firebase version > 8. We will update the template to Firebase latest version as soon as possible but currently it uses version 7. So please use the versions from the package.json. Thanks

djabif avatar Jun 21 '21 13:06 djabif

@djabif any updates on this? We are now having the same issue with the latest version but not quite sure if it is the same issue with this or not. Should we use the one from your previous message in 2021?

"firebase": "^9.16.0",
"@angular/fire": "^7.5.0",

Smilefounder avatar Feb 02 '23 17:02 Smilefounder

Hi, sorry but I don't work anymore on this project. You can try to ping @agustinhaller , he may be able to guide you on this.

djabif avatar Feb 02 '23 18:02 djabif