0
votes

I've just started using Firebase, and I'm trying to implement Cloud Firestore and Authentication in my app. Let me explain the context: my web app will be implemented in a LMS (Learning Management System) like Moodle and Docebo, and will have SCORM compliance. It will be, essentially, a training course with some nice interactive features. The app will be serverless (or better, it will interact with the LMS backend, residing on my client's server), passing and receiving data by Firestore.

I think I've set-up everything for this project, but I can't wrap my head around the authentication system. Basically, the authentication will happen at the LMS level: the user will sign-up and login to the LMS, and then will start using my app. I can extract data from the LMS, such as the user's name and her unique ID.

So I don't need to do a double authentication using the Firebase Auth system (mail and password), the user is already logged in by the time she enters my app. However, I would still need authentication features provided by Firebase, like control rules for the database, and I will need also to keep a database for all the users, with username, id, e-mail and some additional fields.

How can I solve this? I would need a SignInWithEmailAndPassword method, but without the need to enter a valid e-mail / password. Just the ID/token that I can retrieve from the LMS.

1

1 Answers

0
votes

Once you call signInWithEmailAndPassword... the first time you run the code, the user is automatically logged in. If your application is not uninstalled the user will stay authenticated until you call firebase.logout function.

When you first call the signInWithEmailAndPassword successfully, you can be able to get the current userId with

 FirebaseAuth.getInstance().getCurrentUser().getUid 

Then with the userid. You can be able to create a document inside firestore's USERS collection with the same key as the userid.

Then inside the document you can save the data of the user.