🔥 Firebase provides several easy-to-use authentication methods that we can use to handle auth in React apps.
In this lesson, we will cover how to authenticate a user via an email and password. This is done using createUserWithEmailAndPassword
function available to us from the firebase
library.
You'll need firebase configured in your application which you can read about here.
Faraz Ahmad: [0:00] After we've configured Firebase with our configuration options, we were able to use the Firebase library in our application. In this file, if the user is not authenticated, we display a SignupForm. If they are authenticated, we will display a message along with the user object that is returned from Firebase.
[0:18] First, import firebase from "firebase/app" and also import the auth module. We're going to use the createUserWithEmailAndPassword function and pass in our email and password from state. We'll make this an async function and await the user that is returned from firebase.auth(). createUserWithEmailAndPassword.
[0:41] Once we get the user, we'll pass it to our onSuccess callback. After the user fills out the form, they will be authenticated and can see our app along with the user object.
Member comments are a way for members to communicate, interact, and ask questions about a lesson.
The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io
Be on-Topic
Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.
Avoid meta-discussion
Code Problems?
Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context
Details and Context
Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!