Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,240 --> 00:00:05,050
In this lecture, we're going to register the user by submitting their data to Firebase.
2
00:00:05,250 --> 00:00:10,260
We're going to need to turn on the authentication feature in Firebase before we can do so.
3
00:00:10,530 --> 00:00:14,850
Otherwise, Firebase will reject any authentication attempts we make.
4
00:00:15,360 --> 00:00:18,240
Open the firebase console for your project.
5
00:00:18,450 --> 00:00:21,180
On the sidebar, click on authentication.
6
00:00:23,720 --> 00:00:30,230
Firebase will give us the following message, authenticate and manage users from a variety of providers
7
00:00:30,230 --> 00:00:31,910
without server side code.
8
00:00:32,509 --> 00:00:38,370
Nowadays, many platforms allow users to register to other sites by sending their data to this site.
9
00:00:38,390 --> 00:00:42,300
They'd like to register to it's quick, easy and flexible.
10
00:00:42,620 --> 00:00:47,540
Some examples of platforms that provide this service are Facebook, Twitter and Google.
11
00:00:47,930 --> 00:00:53,870
These companies are what Firebase is referring to when it uses the word provider to view the list of
12
00:00:53,870 --> 00:00:54,640
providers.
13
00:00:54,650 --> 00:00:57,140
We can switch to the signing method tab.
14
00:00:59,640 --> 00:01:05,760
Firebase supports multiple platforms out of the box, the method will select is the e-mail method,
15
00:01:06,030 --> 00:01:08,460
enable it but don't enable the password.
16
00:01:08,490 --> 00:01:09,210
This option.
17
00:01:11,700 --> 00:01:18,800
We want to be able to store the password after enabling it click save the status will change to enabled.
18
00:01:19,080 --> 00:01:25,370
We can start adding users to our firebase application will want to do so through Firebases API.
19
00:01:25,980 --> 00:01:28,830
The next step is to send the data to Firebase.
20
00:01:29,070 --> 00:01:33,540
We already have an instance of Firebase that'll help us do that in your editor.
21
00:01:33,660 --> 00:01:35,910
Open the register form component.
22
00:01:38,340 --> 00:01:43,750
Scroll down to the register function, this function is where we handle the registration submission.
23
00:01:44,070 --> 00:01:46,970
We've already taken care of adding the alert messages.
24
00:01:47,250 --> 00:01:50,230
We'll use the firebase instance to send the data.
25
00:01:50,520 --> 00:01:57,090
However, the firebase instance is not available and the component will need to import it at the top
26
00:01:57,090 --> 00:01:57,780
of the script.
27
00:01:57,780 --> 00:02:00,510
Block import the firebase instant's.
28
00:02:05,390 --> 00:02:11,240
It's important that we're importing the firebase file we created in their previous lecture, we don't
29
00:02:11,240 --> 00:02:15,380
want to import the firebase module mistakenly, they are not the same.
30
00:02:15,680 --> 00:02:22,310
One simple trick for making sure you're importing files from the source directory is to use the character.
31
00:02:22,730 --> 00:02:28,490
WINPAC will replace the character in import statements with the path to the source directory.
32
00:02:29,180 --> 00:02:30,770
There are two benefits to this.
33
00:02:30,980 --> 00:02:35,550
It saves you from having to move up multiple directories if your files are nested.
34
00:02:35,810 --> 00:02:39,760
Secondly, you don't have to update the import statements in the file.
35
00:02:39,770 --> 00:02:45,470
If you move it to another directory, the import statements will still be able to import the files you
36
00:02:45,470 --> 00:02:45,840
want.
37
00:02:46,250 --> 00:02:50,360
We are going to use the add character in our components whenever possible.
38
00:02:50,900 --> 00:02:53,840
Go back to the register function definition.
39
00:02:54,140 --> 00:02:57,550
We're going to write the code in between the message alert updates.
40
00:02:57,860 --> 00:03:01,920
The first thing we'll do is invoke the firebase dot off function.
41
00:03:04,500 --> 00:03:10,710
The afunction will return an object with methods and properties we can use to communicate with the authentication
42
00:03:10,710 --> 00:03:17,670
service in the resource section of this lecture, I provide a link to the Authentication SDK documentation
43
00:03:17,670 --> 00:03:18,180
page.
44
00:03:20,760 --> 00:03:27,530
Firebase tells us the following, do not call this constructor directly and said, use Firebase Dot
45
00:03:27,630 --> 00:03:28,140
off.
46
00:03:28,710 --> 00:03:35,050
In most examples, you will find Firebase creating an object using the firebase function.
47
00:03:35,400 --> 00:03:40,870
This function will give you access to the properties and methods listed on this documentation page.
48
00:03:41,370 --> 00:03:46,070
The method will want to use is called create user with e-mail and password.
49
00:03:46,260 --> 00:03:47,700
Click on it from the list.
50
00:03:50,340 --> 00:03:57,390
According to the documentation, it expects the email and password as arguments, the returned value
51
00:03:57,390 --> 00:03:58,350
is a promise.
52
00:03:58,650 --> 00:04:01,920
The promise will give us an object with the user's credentials.
53
00:04:01,920 --> 00:04:08,520
If the authentication was a success, the description says the following about the function creates
54
00:04:08,520 --> 00:04:15,990
a new user account associated with the specified email address and password unsuccessful creation of
55
00:04:15,990 --> 00:04:16,970
the user accounts.
56
00:04:17,190 --> 00:04:20,339
This user will also be signed into your application.
57
00:04:20,610 --> 00:04:26,340
User account creation can fail if the account already exists or the password is invalid.
58
00:04:26,940 --> 00:04:28,530
This one note is important.
59
00:04:28,770 --> 00:04:33,960
Firebase will automatically log the user in if their account was created successfully.
60
00:04:34,320 --> 00:04:35,760
Will want to reload the app.
61
00:04:35,760 --> 00:04:36,780
If that's the case.
62
00:04:37,200 --> 00:04:40,440
Reading further, we'll find a list of possible errors.
63
00:04:42,830 --> 00:04:48,920
Lastly, there's an example we can use, we won't use the example they provide, we're going to take
64
00:04:48,920 --> 00:04:51,630
a slightly different approach than the default example.
65
00:04:51,860 --> 00:04:53,360
Let's go back to the ED.
66
00:04:55,880 --> 00:05:00,320
We're going to chain the create user with email and password function.
67
00:05:03,930 --> 00:05:10,400
This function will return, I promise, but I don't want to change the then or catch functions and said
68
00:05:10,560 --> 00:05:15,570
we'll use the async away keywords before the register of function name.
69
00:05:15,570 --> 00:05:17,340
Add the async keyword.
70
00:05:19,740 --> 00:05:27,180
Will add the await key word before the firebase function, the create user function will send a request
71
00:05:27,180 --> 00:05:33,450
to Firebase with the information you've provided it, if successful, will be returned with the user's
72
00:05:33,450 --> 00:05:37,990
credentials, will want to store these credentials to keep the user logged in.
73
00:05:38,640 --> 00:05:43,350
We're going to assign the response to a variable called user credentials.
74
00:05:45,820 --> 00:05:52,780
We can't forget about the arguments will pass those in next, the documentation says the first argument
75
00:05:52,780 --> 00:05:55,540
is the email and the second is the password.
76
00:05:55,900 --> 00:06:02,590
Both values are stored and the values parameter we are provided, the values from the submit event we
77
00:06:02,590 --> 00:06:08,830
don't need to store the values in a data object will pass in both values to their respective arguments.
78
00:06:11,340 --> 00:06:17,970
The values from the fields can be retrieved by their names, we assign them the property names, corresponds
79
00:06:17,970 --> 00:06:24,810
to the name attributes on the field components with this one function or able to completely register
80
00:06:24,810 --> 00:06:27,580
the user in the system in the next lecture.
81
00:06:27,630 --> 00:06:29,910
We'll look at handling the response.
8542
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.