1 00:00:00,990 --> 00:00:02,220 Instructor: At the end of the last section, 2 00:00:02,220 --> 00:00:04,800 I was unable to get an error message to show up 3 00:00:04,800 --> 00:00:06,540 when I tried to sign in or sign up 4 00:00:06,540 --> 00:00:08,610 with a email that's already been in use. 5 00:00:08,610 --> 00:00:09,443 So it turns out 6 00:00:09,443 --> 00:00:12,270 I simply had not refreshed my browser properly. 7 00:00:12,270 --> 00:00:13,650 If I click on sign up again, 8 00:00:13,650 --> 00:00:14,850 you'll notice that I am in fact 9 00:00:14,850 --> 00:00:16,440 seeing the error message appear. 10 00:00:16,440 --> 00:00:18,210 So that's very good. 11 00:00:18,210 --> 00:00:20,520 Now that our user has the ability to sign up 12 00:00:20,520 --> 00:00:21,750 to our application, 13 00:00:21,750 --> 00:00:24,300 we need to make sure that after they successfully sign up 14 00:00:24,300 --> 00:00:25,200 for a new account, 15 00:00:25,200 --> 00:00:28,500 we try to redirect them over to the feature route. 16 00:00:28,500 --> 00:00:30,660 Remember, the feature route is supposed to be protected 17 00:00:30,660 --> 00:00:33,450 from users who are not signed into our application. 18 00:00:33,450 --> 00:00:35,250 So, let's figure out how to do this. 19 00:00:36,120 --> 00:00:37,050 To make sure that a user 20 00:00:37,050 --> 00:00:40,350 is able to get automatically redirected over, 21 00:00:40,350 --> 00:00:42,450 we're gonna find our signup component, 22 00:00:42,450 --> 00:00:44,070 here it is right here, 23 00:00:44,070 --> 00:00:46,230 and inside the onSubmit Handler 24 00:00:46,230 --> 00:00:49,710 where we are calling our signup Action creator, 25 00:00:49,710 --> 00:00:52,920 We are gonna pass a callback to this thing. 26 00:00:52,920 --> 00:00:56,370 So as a second argument to the signup action creator, 27 00:00:56,370 --> 00:00:58,290 I'm gonna pass in a callback 28 00:00:58,290 --> 00:01:00,060 that will be automatically called 29 00:01:00,060 --> 00:01:02,253 after user successfully signs up. 30 00:01:03,210 --> 00:01:04,980 Inside this callback function 31 00:01:04,980 --> 00:01:07,020 I'm going to do that navigation step 32 00:01:07,020 --> 00:01:10,230 that will send a user over to that feature route. 33 00:01:10,230 --> 00:01:14,070 So inside of here, to automatically redirect our user, 34 00:01:14,070 --> 00:01:15,990 we're going to get that props object 35 00:01:15,990 --> 00:01:20,610 or that history prop that we get provided by Redux Router. 36 00:01:20,610 --> 00:01:24,390 We'll say this.props.history.push 37 00:01:24,390 --> 00:01:27,333 and we're gonna send them over to the feature route. 38 00:01:30,030 --> 00:01:33,183 Then we'll flip back over to our signup action creator. 39 00:01:35,220 --> 00:01:37,620 So here's my signup action creator. 40 00:01:37,620 --> 00:01:39,510 I'm gonna make sure that I record, 41 00:01:39,510 --> 00:01:42,840 that we get a second prop in here 42 00:01:42,840 --> 00:01:45,213 and I will call it, callback, like so. 43 00:01:46,530 --> 00:01:49,020 So then inside of my try statement 44 00:01:49,020 --> 00:01:51,090 after we get back response 45 00:01:51,090 --> 00:01:52,770 and after we dispatch an action 46 00:01:52,770 --> 00:01:55,320 saying that the user is now signed in, 47 00:01:55,320 --> 00:01:56,943 I will call that callback. 48 00:01:58,380 --> 00:01:59,970 So when we try to call the callback 49 00:01:59,970 --> 00:02:00,840 that's going to make sure 50 00:02:00,840 --> 00:02:03,333 that our user gets automatically redirected. 51 00:02:04,170 --> 00:02:05,310 So I'll save this file 52 00:02:05,310 --> 00:02:07,760 and we'll test this out again inside the browser. 53 00:02:09,539 --> 00:02:10,560 Back inside my browser, 54 00:02:10,560 --> 00:02:12,393 I'll let the refresh kick in. 55 00:02:16,620 --> 00:02:21,270 I'll then go to my signup route and I'll create a new login. 56 00:02:21,270 --> 00:02:23,130 So for this one, we don't really need anything, 57 00:02:23,130 --> 00:02:27,415 I'll just put in gibberish, and now when I click on signup, 58 00:02:27,415 --> 00:02:30,510 I get automatically redirected over to the feature route. 59 00:02:30,510 --> 00:02:34,500 Awesome, okay, so that's another step forward. 60 00:02:34,500 --> 00:02:36,393 Let's continue in the next section.