Firebase Auth Tutorial #15- Firestore Users Collection
Why Stack Overflow recommends it
Stack Overflow users link it when they need a worked example of pairing Firebase Auth with a Firestore users collection to hold profile data like usernames and bios.
Recommended by 1 people across 1 different months, 2019 to 2023.
What it is
Part 15 of Net Ninja's Firebase Auth series, a coding tutorial in which Shaun Pelling shows how to create a Users collection in Firestore and store extra profile data (such as a bio) when a user signs up. It builds on earlier episodes using Firebase Auth, Firestore and Materialize in plain JavaScript.
What people said
Recommends Tanner · 2020-03 · Stack Overflow · on “Make username unique and save it on the Firebase Database”
You can't create profile fields on the the auth user beyond what's already there. For username, you're best off creating a users collection in firestore. Each entry can be keyed by the user's UID assigned from auth . When you create the entry, create it with a username field. Then, before any new users lock in their username, you can run a query against firestore with a where('username', '==', $username) where $username is the name the user is attempting to reserve. If the record exists, the username is taken and the user will have to choose something else. Here's a YouTube tutorial on using auth and firestore together for use cases like yours: [this video]
Cites Holger Mueller · 2019-12 · Stack Overflow · on “Using vuex, firestore, and createUserWithEmailAndPassword, how do I create a user profile collection when a user registers?”
For the app I'm building, I want my users to have a profile created for them when they register; the profile would contain the user's username, email, and the uid created by firebase authentication. I've got the authentication portion using createUserWithEmailAndPassword to work on its own. I'm also able to create a "users" collection, capturing a username and the user's email, on its own as well. However, I'm running into trouble grabbing and saving the uid to the user's profile in the user's collection. Here is the code I have at the moment: import * as firebase from "firebase/app"; import db from "../../components/firebase/firebaseInit"; actions: { registerUser({ commit }, payload) { comm
Cites 704 · 2020-08 · Stack Overflow · on “At what point during FirebaseUI auth process can I access user credentials?”
Referring to this official example [LINK] from the Next.js github that shows using firebase auth with next. Many projects I study, at some point use createUserWithEmailAndPassword. With this they can **use the user credentials to do things like creating a new document in a 'users' collection in a firestore database. This stack answer [LINK] and this tutorial [this video] refer to this method. The example I linked to, (i think) uses firebase-ui - the auth part of my code looks like this: const firebaseAuthConfig = { signInFlow: 'popup', // Auth providers // [LINK] signInOptions: [ { requireDisplayName: true, provider: firebase.auth.EmailAuthProvider.PROVIDER_ID, }, ], signInSuccessUrl: '/', creden
Cites Benjamin Virgin · 2023-01 · Stack Overflow · on “I am doing a tutorial to learn firebase and it uses an earlier version of firebase. What is the firebase 9 syntax for this code?”
Here is the link to the part of the tutorial I am working with: [this video] Here is the code that I have from the tutorial. I have looked all over the internet to try and get this to work. The goal is to display a persons bio that they typed in when signing up to the site. I think the issue lies on the line db.collection('users').doc(user.uid.get().then(doc => {... but I'm not sure. Any help would be great. thanks! `const setupUI = (user) => { if (user) { // account info db.collection('users').doc(user.uid).get().then(doc => { const html = ` <div>Logged in as ${user.email}</div> <div>${doc.data().bio}</div> `; accountDetails.innerHTML = html; }); // toggle user UI elements loggedInLinks.forEach(