This video is available to students only

Adding authorization methods

Adding authorization methods

In this lesson we are going to implement basic authorization methods in our application. Those methods are:

  • Login

  • Sign up

  • Reset password

We are going to keep all our authorization methods in the auth-api.js file inside the api folder.

Sign up#

Let's start with the Sign up method. We are going to implement it in RegisterScreen. We already have the inputs so all we need to do is create a function that takes the data and creates a new account in Firebase. We can find information about the register method in the Firebase documentation.

Before we can implement it, we go back to our project in the Firebase console. Select the Authorization page and then head to the Sign-in method tab. Here we enable Email/Password provider. It will allow users to create accounts with their email and password.

Once this is done, let's create a signUpUser method inside auth-api.js file. We could copy the code provided in the documentation but it's not the best syntax for modern JavaScript. We can improve it with async/await. Our final function looks like this:

 

This page is a preview of Creating a React Native Login

Start a new discussion. All notification go to the author.