1 00:00:00,690 --> 00:00:06,410 And once we have registered user of course we also would want to set up our log in functionality where 2 00:00:06,500 --> 00:00:08,570 if the user has already registered. 3 00:00:08,900 --> 00:00:15,130 Well now we would just like to sign in and the functionality is going to be very very similar. 4 00:00:15,150 --> 00:00:20,560 And again we're going to start with using the log and user function that we imported. 5 00:00:20,720 --> 00:00:25,140 And of course that is done if the member has already registered. 6 00:00:25,160 --> 00:00:27,350 So let me uncommon this. 7 00:00:27,350 --> 00:00:34,070 And then again we're going to pass in the object or in this case I'm looking for only email as well 8 00:00:34,070 --> 00:00:35,270 as the password. 9 00:00:35,270 --> 00:00:42,610 And again it's gonna be the same thing where if the IS members true then of course our response is gonna 10 00:00:42,620 --> 00:00:45,190 be equal to a log in user. 11 00:00:45,500 --> 00:00:46,030 OK. 12 00:00:46,070 --> 00:00:52,030 Before that we use the register but our logic after that is not going to change if it is success. 13 00:00:52,190 --> 00:00:55,140 We're gonna do something we can navigate away from page. 14 00:00:55,220 --> 00:01:00,380 Currently we're just showing our user object but eventually of course we're going to do something. 15 00:01:00,380 --> 00:01:06,300 If not if we're not able to log in well then we're just going to show some kind of alert. 16 00:01:06,310 --> 00:01:06,960 All right. 17 00:01:06,980 --> 00:01:09,680 Now let's save log in. 18 00:01:09,710 --> 00:01:10,940 That is correct. 19 00:01:10,970 --> 00:01:16,910 And now let's head over back to our strappy log in user so log in user again is empty and like I said 20 00:01:17,210 --> 00:01:20,660 it's going to be very very similar to what we already had. 21 00:01:20,720 --> 00:01:22,820 So you could technically copy paste. 22 00:01:22,850 --> 00:01:27,940 But in my case I'm just going to rewrite this axioms from axioms. 23 00:01:28,070 --> 00:01:36,530 Then we're also gonna have a URL import your URL so let's navigate to utilize then once we're new tools 24 00:01:36,530 --> 00:01:40,870 we're gonna look for your URL then the function is gonna be of course a single. 25 00:01:41,390 --> 00:01:49,200 So we're gonna go with a sync function then we're going to log in the user log in user again I'm gonna 26 00:01:49,220 --> 00:01:57,050 pass in the object because I just don't like to deal with an order of my arguments password and then 27 00:01:57,050 --> 00:01:58,340 within the function body. 28 00:01:58,340 --> 00:02:08,270 Well first of all maybe export export default log in user log in user and then within a function body 29 00:02:08,270 --> 00:02:14,710 again we're gonna have a response so concert response is equal to a weight. 30 00:02:14,720 --> 00:02:20,990 So we're gonna wait till our promise is settled and then we're going to use x years post request and 31 00:02:20,990 --> 00:02:27,500 then the URL in this case again is going to be a template string and we're gonna pass in our You are 32 00:02:27,500 --> 00:02:28,350 all variable. 33 00:02:28,700 --> 00:02:36,770 So let me grab first my variable your URL and then the path is off and then a local. 34 00:02:36,770 --> 00:02:41,970 So instead of register we're just adding a local and then we're still passing in the data. 35 00:02:42,080 --> 00:02:47,150 So there's going to be a data object with a property name is identifier like I mentioned in the last 36 00:02:47,150 --> 00:02:50,360 video when working with strappy we have two options. 37 00:02:50,510 --> 00:02:54,660 We could either use the email or we could use the user name. 38 00:02:54,710 --> 00:03:01,160 Now in my case I set it up everything as email just for simplicity's sake but in general if you'd want 39 00:03:01,520 --> 00:03:04,340 you can pass in either of these two values. 40 00:03:04,490 --> 00:03:09,740 That's the reason why within the log and user in fact the property is not email where it's not a user 41 00:03:09,740 --> 00:03:10,190 name. 42 00:03:10,190 --> 00:03:15,400 The property is identifier if by her like so. 43 00:03:15,410 --> 00:03:18,620 And then in case of course I'm going to set the C equal to email. 44 00:03:18,740 --> 00:03:22,520 That's the reason why you could set this up to as a user name as well. 45 00:03:23,030 --> 00:03:24,960 And then let's also add the password. 46 00:03:25,070 --> 00:03:30,860 Now in this case of course I'm going I'm using iOS 6 thing where since the parameter values exactly 47 00:03:30,860 --> 00:03:32,570 the same as my password. 48 00:03:32,590 --> 00:03:34,630 Now that's the reason why can I have a shortcut. 49 00:03:34,820 --> 00:03:36,930 And also I'm going to use catch. 50 00:03:37,040 --> 00:03:42,190 So right away I'm going to change that catch and we're just going to console log there. 51 00:03:42,230 --> 00:03:43,690 So let's look for a log. 52 00:03:43,820 --> 00:03:51,260 Let's delete a semicolon and let's control log there and just like register user we're just gonna return 53 00:03:51,260 --> 00:03:58,010 response whatever that response is either it's gonna be undefined or in fact is gonna be our object 54 00:03:58,450 --> 00:04:01,170 now head over back to a log in J. 55 00:04:01,250 --> 00:04:01,890 Yes. 56 00:04:02,040 --> 00:04:03,750 And I guess let's start out. 57 00:04:03,760 --> 00:04:09,950 I'm gonna we're gonna have either success with our user object or there's gonna be undefined and we're 58 00:04:09,950 --> 00:04:16,690 gonna have an error and since our only user of course is John well I'm gonna try to log in as John so 59 00:04:16,690 --> 00:04:19,910 that gmail dot com hopefully my password is gonna be correct. 60 00:04:19,920 --> 00:04:27,770 So my simple password and success I have the success where I successfully logged in as John. 61 00:04:27,770 --> 00:04:29,890 Now of course nothing happens on my front end. 62 00:04:30,080 --> 00:04:32,780 We haven't attached that functionality to anything. 63 00:04:32,830 --> 00:04:39,770 What we have right now but I can clearly see that I'm getting back a nice response where I have my data 64 00:04:40,090 --> 00:04:42,200 and I have my token. 65 00:04:42,200 --> 00:04:47,250 Now let's also try to do that by let's say forgetting our password. 66 00:04:47,270 --> 00:04:52,730 So in this case I'm just going to type some kind of I don't know dummy password like so and then of 67 00:04:52,730 --> 00:04:57,620 course I'm gonna get an error because I wasn't able to in fact log in. 68 00:04:57,620 --> 00:05:04,330 So once we take a look at that then we can start working on setting up our user on the front end. 69 00:05:04,400 --> 00:05:10,730 So now that we know that we can log in our user in the stripy as well as register user in a strappy 70 00:05:11,120 --> 00:05:16,530 now of course we can start setting up our user where we're controlling of what we're displaying for 71 00:05:16,530 --> 00:05:18,430 the user on our front end.