1 00:00:01,330 --> 00:00:09,910 well in this video we are going to continue with the continuation of the previous one in which we saw that we cannot 2 00:00:11,990 --> 00:00:19,010 work with the state variables of the context when creating protected routes and 3 00:00:20,789 --> 00:00:28,570 you had to understand why it is necessary to use that touch that we are generating with 4 00:00:28,570 --> 00:00:35,829 the cookie is worth the idea is that touch in that we have in our cookie send it to 5 00:00:38,109 --> 00:00:45,049 the back end and the back end when it takes it remember that part of the information of 6 00:00:46,509 --> 00:00:54,850 that touch that we created with the jwt was the user's idea then the back end when it receives 7 00:00:54,850 --> 00:01:01,109 token has to extract that idea, launch a consultation to our mongo database, 8 00:01:01,109 --> 00:01:09,310 verify that that user exists and then we do accept that token as good, okay, 9 00:01:09,310 --> 00:01:15,069 then a little that is what we have to do now, so if I want to send 10 00:01:15,069 --> 00:01:22,609 information from the front to the back in what we are doing all the time is 11 00:01:24,849 --> 00:01:49,349 Well, by routes, then we associate each of those routes with a function, we had our routes and we associated the login page, the register page, so we are going to have a route to a backend route, we are going to associate it through Axios 12 00:01:49,349 --> 00:01:57,409 y le vamos a decir pues bueno pues cuando el usuario o el propio from manda información a 13 00:01:57,409 --> 00:02:04,790 esa ruta pues entonces qué es lo que quiero qué elemento qué función quiero que se ejecute 14 00:02:04,790 --> 00:02:12,949 entonces me vengo al out js y aquí me voy a crear como siempre una función flecha que le voy a 15 00:02:12,949 --> 00:02:21,569 call it, for example, I call it verification, verification, touch it, it is worth 16 00:02:26,250 --> 00:02:31,110 that this in principle we do not send anything 17 00:02:33,310 --> 00:02:40,889 here I am going to receive an answer this is going to be the same as instance instance is to remember why 18 00:02:40,889 --> 00:02:49,530 we had created the axis js to initialize our connection our axis and that it did not give us 19 00:02:49,530 --> 00:02:56,849 credentials or cores errors when we tried to use those context variables when we tried to 20 00:02:56,849 --> 00:03:04,770 that touch in this case to be great because I am not going to take anything from the back in what I want is 21 00:03:04,770 --> 00:03:14,949 well, send that information to him, but then return it to me to return the information of 22 00:03:14,949 --> 00:03:20,169 whether that user is correct or not, I am not going to register anything in the database, I am not going to leave anything, 23 00:03:20,169 --> 00:03:28,449 then I do not use the post protocol, I use the get, okay and in the get we are going to put it 24 00:03:28,449 --> 00:03:33,689 because it is the route that, for example, that route right now does not exist, now I have to do it, 25 00:03:33,689 --> 00:03:41,150 then I can put verification or as we are putting everything in English because we can put 26 00:03:41,150 --> 00:03:51,590 verify ok and it would be then this function is the one we have in the front and the one that is going to 27 00:03:51,590 --> 00:03:58,689 be put through axios in contact with the back-end receiving the back-end that touch is worth and the 28 00:03:58,689 --> 00:04:09,129 backend is going to do the tasks that I am telling you to extract the idea and launch a query 29 00:04:09,129 --> 00:04:17,410 against mongo to verify that that user exists and answer the front saying and that user if it 30 00:04:17,410 --> 00:04:22,949 exists or that user does not exist it is valid or that user if it exists but the touch that they have sent me is 31 00:04:22,949 --> 00:04:32,709 erroneous, there are different cases there that we have to control, then I am going to leave 32 00:04:32,709 --> 00:04:43,579 now the front part ok and I am going to come to the back end part then client I am going to minimize it 33 00:04:45,060 --> 00:04:50,779 and we are in the back end part then in the part of the you are seeing the code 34 00:04:50,779 --> 00:05:00,180 in the backend part we have our routes here, okay, so what am I going to do? Well, 35 00:05:00,180 --> 00:05:05,019 that one that I have created a new router dot get 36 00:05:08,860 --> 00:05:19,500 verify, okay, and what I want is okay when a get request enters the verify route I want it to be 37 00:05:19,500 --> 00:05:27,620 execute a function, it is worth the same as we had here in middleware or the different functions in 38 00:05:27,620 --> 00:05:36,279 this case there is nothing in middleware or anything like that I am going to say here verification we are going to put 39 00:05:38,860 --> 00:05:47,220 touch touch verification ok I call it the same as in the from and so we do not get lost ok 40 00:05:47,220 --> 00:05:55,680 this function this token verification does not exist, it is worth then where we are controlling 41 00:05:55,680 --> 00:06:02,279 all these functions of the register log in the file in the out it is worth all this we are doing it from 42 00:06:02,279 --> 00:06:08,459 the controllers in out controller js then in out controller js we had all these 43 00:06:09,980 --> 00:06:15,560 functions to which we exported and then we continued calling them from the routes, it is worth 44 00:06:15,560 --> 00:06:20,959 then what am I going to do? Well, create this new one 45 00:06:21,500 --> 00:06:27,279 that we have called token verification is worth then 46 00:06:27,279 --> 00:06:35,560 for token verification we are going to see that token access 47 00:06:35,560 --> 00:06:42,819 and we are going to need the jw 48 00:06:42,819 --> 00:06:50,180 because we have to verify that touch that we are receiving from the front with the one that 49 00:06:50,180 --> 00:06:57,339 generates the one that is generated through the id that we have saved from our users, it is worth 50 00:06:57,339 --> 00:07:04,339 remembering that with jw we can make that comparison then I will need that jw 51 00:07:04,339 --> 00:07:10,579 I'm going to import jw t 52 00:07:12,579 --> 00:07:20,589 jason web 53 00:07:21,350 --> 00:07:27,470 what else can we need the jw t remember that we play with in this case a 54 00:07:27,470 --> 00:07:31,709 couple of keys or we could play with a couple of keys or a encryption key 55 00:07:31,709 --> 00:07:37,910 we played with an encryption key that we had 56 00:07:37,910 --> 00:07:44,389 in conflict in conflict the touch in secret is worth that the course of am 2 2024 3 that 57 00:07:44,389 --> 00:07:49,910 I will also need it because we are going to put it we are going to import it then here 58 00:07:51,670 --> 00:08:00,750 we import the touch in secret and it recognizes me perfect we may need something else 59 00:08:00,750 --> 00:08:08,129 I think not I think that with the jw and the touch well if we need something else because as 60 00:08:08,129 --> 00:08:15,269 always we are putting it ok and now we are going to create our function ok our function 61 00:08:15,269 --> 00:08:23,089 of token verification we have not called it token verification token verification yes ok 62 00:08:23,089 --> 00:08:38,220 then come to it then export with verification touch these is worth and since we are then 63 00:08:38,220 --> 00:08:50,049 we are going to put in here that it also brings us verification so then I do not forget 64 00:08:50,049 --> 00:09:00,610 vale verificación toque esto como vamos a ir contra mongo y bueno y puede haber posibles 65 00:09:00,610 --> 00:09:12,169 errores con más o menos facilidad a zinc vale vale esto va a recibir un rey y un res como 66 00:09:12,169 --> 00:09:20,070 always worth a request and a response is worth the answer and the data that comes from the client is worth 67 00:09:20,070 --> 00:09:36,679 we do our arrow function come on ok we are going to take with what I need the 68 00:09:36,679 --> 00:09:48,220 the touch that we have that we are sending from the front is worth then that cookie 69 00:09:51,480 --> 00:09:57,240 what we are sending are the cookies ok that cookie is called touch then what I want is 70 00:09:57,240 --> 00:10:05,649 touch constant in this is equal to the point 71 00:10:07,909 --> 00:10:27,929 ok ok now we start to ask questions this is strange to me this is worth it you have to be 72 00:10:27,929 --> 00:10:37,269 aware of it because well it did not seem like with that ok well then 73 00:10:37,269 --> 00:10:44,649 we start to ask the questions, the first one may not exist, so if 74 00:10:47,490 --> 00:10:59,570 they touch if there is no touch, it is not empty, then we are going to do a return, we return a 75 00:10:59,570 --> 00:11:10,379 status point that is, for example, the 401 that if you remember this one that we have already used it 76 00:11:10,379 --> 00:11:25,980 is the unauthorized one, then we are going to put it instead of unauthorized because I am going to put it 77 00:11:25,980 --> 00:11:50,000 not touch there is no touch for example okay this is this I try to that cookie that comes to us from the 78 00:11:50,000 --> 00:11:57,159 front rack is worth and from all the cookies that can come then I ask as it is key value 79 00:11:57,159 --> 00:12:08,620 ok I ask for the key to be touch that should save if it exists ok that touch that we have 80 00:12:08,620 --> 00:12:16,539 created if it touches it is empty then it tells me you send me a message to the response to the front with the 81 00:12:16,539 --> 00:12:25,899 code 401 and that you tell me that the touch does not exist now that touch if it exists ok what am I going to 82 00:12:25,899 --> 00:12:38,500 do? Well, a JWT point verify, okay, I want you to verify the token that you just took on the one hand, okay 83 00:12:40,519 --> 00:12:49,740 with the touch in secret that for that we had taken it and this we are going to create another 84 00:12:49,740 --> 00:12:59,399 function asynchronous this function here inside it is worth that it is going to 85 00:12:59,399 --> 00:13:09,299 I will tell you it will generate or an error or it will be able to collect the data of that user that 86 00:13:09,299 --> 00:13:16,919 we are taking out through the touch that we have received from the front ok then here 87 00:13:16,919 --> 00:13:28,539 well, as I go against the monkey, that is why I also put it as asynchronous, it is not worth then this 88 00:13:28,539 --> 00:13:36,179 can return us or it will generate an error or the data of a user is worth and this is going to be 89 00:13:36,179 --> 00:13:49,710 another arrow function is worth the jw t verify is worth then with this is what I say if 90 00:13:51,509 --> 00:13:59,389 what is produced is an error is worth if yesterday then what am I going to tell you because it is worth 91 00:13:59,389 --> 00:14:11,389 because it returns the same thing as before, it is worth the status point 401 json 92 00:14:12,710 --> 00:14:16,990 and here we can put 93 00:14:16,990 --> 00:14:30,129 let's see, we can put it here, yes, we have sent the token variable, okay, what happens 94 00:14:30,129 --> 00:14:38,049 is that when we have tried to use the jwt point verify to compare it is worth to extract that 95 00:14:38,049 --> 00:14:43,090 id and see if that user exists, that user does not exist then 96 00:14:45,809 --> 00:14:51,870 we are going to or that idea does not exist then we are going to and we are going to say 97 00:14:53,629 --> 00:15:11,159 touch touch is incorrect ok this is if it returns us an error ok what happens if it does not return us 98 00:15:11,159 --> 00:15:21,840 an error? Well, we are going to launch it, user found, okay? If when you do the verify it does not 99 00:15:21,840 --> 00:15:28,139 return us any error, it means that we do have that ID in the database, okay? And that it 100 00:15:28,139 --> 00:15:35,919 does belong to this dictionary or to this Mongo collection, okay? Then we are going to put 101 00:15:35,919 --> 00:15:44,820 a user fan we are going to tell him the white because we are going to go against mongo and we are going to launch a 102 00:15:44,820 --> 00:15:57,940 consultation with user ok user which is the one we have to control the possible models and such is worth 103 00:15:59,019 --> 00:16:03,779 as a bus that is in the end the one that will also allow us to launch that consultation 104 00:16:03,779 --> 00:16:10,740 because if we put the use the point here we can launch the query that is fine by 105 00:16:10,740 --> 00:16:19,740 and it is worth and what is the id that I want to take because the one that I have taken in user point 106 00:16:20,700 --> 00:16:35,470 and use the point and it is worth in the user when I have taken the verify in the user here 107 00:16:35,470 --> 00:16:41,710 comes the username all the key values ​​that we have saved in that document not in that 108 00:16:41,710 --> 00:16:47,830 dictionary in that key value that we are saving for each of the users within the mungo 109 00:16:47,830 --> 00:16:55,029 must be worth then one of those fields is the one and it is worth then I tell him ok then find me 110 00:16:55,029 --> 00:17:03,970 find by id ok find me by id this user and if you find it you are not going to put the result in 111 00:17:03,970 --> 00:17:08,250 user fan ok then what are we going to do now you can tell him well yes 112 00:17:09,849 --> 00:17:19,589 and it does not exist if you are in the void it is worth no more returned anything in the previous line 113 00:17:19,589 --> 00:17:29,809 then here we are going to put a retun and we are going to put it because again the rest status point 114 00:17:29,809 --> 00:17:39,529 401 jota son 115 00:17:43,829 --> 00:17:47,269 and here we are going to put the user 116 00:17:56,630 --> 00:18:08,289 there is no user related to the touch for example it is worth it, you personalize it, you only put it in English, 117 00:18:08,289 --> 00:18:19,029 what you want to do is worth it if the user found does have information because 118 00:18:19,029 --> 00:18:25,049 what I am going to do is return that information and that is already telling me that that touch is correct 119 00:18:25,049 --> 00:18:36,859 ok then here we are going to put the challenge we are going to put the red dot j son and we are going to 120 00:18:36,859 --> 00:18:41,859 saying it is worth in the field and you are going to see me you are going to return the user found 121 00:18:44,299 --> 00:18:51,420 point this is it was a low id as in the username 122 00:18:53,440 --> 00:19:07,599 you are going to see me the user found point username in the email we are going to send the user 123 00:19:07,599 --> 00:19:19,420 and it is worth and this would be our function in the back end part, it is worth then we would receive 124 00:19:19,420 --> 00:19:28,900 in the network we would receive that touch and well, we would already have possible problems here that 125 00:19:28,900 --> 00:19:33,700 we could find ourselves with, we have done it asynchronously, it is worth above all 126 00:19:33,700 --> 00:19:42,460 especially especially when we are going to have access to our database, which is when 127 00:19:42,460 --> 00:19:48,559 different errors can occur that is active that is not 128 00:19:51,619 --> 00:19:57,660 raised that I know is worth then there is always as well as in the end look 129 00:19:57,660 --> 00:20:03,960 well, well, it would be okay and I would already have my part of the back in 130 00:20:06,500 --> 00:20:12,859 touched ok we have added what we would need to be token verification because in 131 00:20:12,859 --> 00:20:18,859 principle this part would already be ok we are going to continue with the part of the front 132 00:20:20,539 --> 00:20:27,279 I am going to close I am going to close this I do not want to go to the client ok 133 00:20:27,279 --> 00:20:32,440 then in the part of the client we are going to 134 00:20:34,000 --> 00:20:36,839 first 135 00:20:36,839 --> 00:20:43,380 we are going to come to clients rc 136 00:20:43,380 --> 00:20:48,900 we have the answer here is worth first 137 00:20:48,900 --> 00:20:52,740 that we have the register and cookies 138 00:20:52,740 --> 00:20:55,400 ok 139 00:20:55,400 --> 00:21:20,009 here ok here we are here and here we are importing the request register and the login request we are going 140 00:21:20,009 --> 00:21:27,269 to use the token verification then we have to here tell him that I also want to use 141 00:21:27,269 --> 00:21:38,150 this is a comma token verification ok ok this we are also going to use it in our context 142 00:21:38,150 --> 00:21:48,690 now we are in the file of the outcontext.js x and from here the idea is that every time the page is loaded 143 00:21:48,690 --> 00:21:53,130 that was the problem we had with the context variables every time that page is recharged 144 00:21:53,130 --> 00:22:04,250 we are going to create or we are going to better said to control that that event is not to reload and that 145 00:22:04,250 --> 00:22:11,369 event that we already know that it is with the use effect what we are going to do is control or send 146 00:22:11,369 --> 00:22:22,750 information to that verify that we have used in I will say it in the back-end ok and with the 147 00:22:22,750 --> 00:22:31,670 response that you send me I will know if that user exists or not ok then we go with it we are going to 148 00:22:31,670 --> 00:22:46,099 create a new function that we are going to call this one, we can leave it, I don't care, I'm going to 149 00:22:46,099 --> 00:23:01,589 leave it, okay, I'm going to leave it and here we are going to put the effect of the effect 150 00:23:04,150 --> 00:23:06,690 we are going to create our arrow function 151 00:23:08,549 --> 00:23:23,769 and in our arrow function what we are going to tell you is what I want is not to control 152 00:23:23,769 --> 00:23:27,609 any variable, what I want is 153 00:23:38,220 --> 00:23:41,220 we check 154 00:23:41,900 --> 00:23:50,509 we verify the touch against the back 155 00:23:50,509 --> 00:23:54,049 ok and here we are going to put 156 00:24:01,009 --> 00:24:05,829 we look at the variables 157 00:24:12,299 --> 00:24:19,460 ok then I have here the use effect that we are going to control that it is done is that it is updated 158 00:24:23,839 --> 00:24:31,220 In the useEffect, it seems to me that in some video we have already seen that you cannot put the Asynchronous, 159 00:24:31,220 --> 00:24:36,019 okay? So what is usually done is within the useEffect, if you see in the documentation, 160 00:24:36,019 --> 00:24:43,400 is that a function is created, as they are created from all life, and then we call that function, 161 00:24:43,400 --> 00:24:48,259 that function that we create within the useEffect, we can put it as Asynchronous, okay? 162 00:24:48,259 --> 00:24:57,140 entonces la forma de jugar cuando queremos jugar cuando queremos contemplar el sincronismo es así 163 00:24:57,140 --> 00:25:03,279 vale entonces aquí yo lo que voy a hacer es crearme una función que le voy a llamar por 164 00:25:03,279 --> 00:25:10,059 ejemplo y que va a ser asíncrona vale que lo que ando buscando y le vamos a llamar función 165 00:25:10,059 --> 00:25:19,059 and we can call it here, for example, the check, we are going to put the check, 166 00:25:23,299 --> 00:25:36,559 the token, the token, for example, something like that, okay, okay, then this function, 167 00:25:36,559 --> 00:25:48,799 lo que le voy a decir es la vas a llamar justo cuando se ejecute el yus efectos aquí le vamos 168 00:25:48,799 --> 00:26:00,160 a poner vale ahora que va a hacer esta función que lo interesante bueno pues primero vamos a 169 00:26:00,160 --> 00:26:10,750 to see if it exists or does not exist in this case and if a cookie has not been generated 170 00:26:13,410 --> 00:26:25,089 is worth cookies get then this because the same thing that we had put before I would need here before 171 00:26:25,089 --> 00:26:35,869 the lift, then we are going to put the same as above, it is worth cookies that variable cookies that is going to 172 00:26:35,869 --> 00:26:43,670 take and a touch is worth and exactly the same as above 173 00:26:43,670 --> 00:26:58,150 ok we are going to take all the cookies that we have in the front we are going to save it inside cookies and 174 00:26:58,150 --> 00:27:08,529 then I am going to ask if there is a cookie that its key is touch ok that there is no such cookie 175 00:27:08,529 --> 00:27:21,289 well, what are we going to do, well, nothing, we are going to put the set and the authenticate to false, okay, we are going to 176 00:27:26,240 --> 00:27:44,069 be you and we put it in values I am going to put it with the retun so that this returns to us, okay 177 00:27:47,170 --> 00:28:01,829 y luego hay una hay una variable de estado que es cargando vale porque a veces sí bueno podemos hacer 178 00:28:01,829 --> 00:28:16,039 qué cuando estás aunque me genere algún tipo de problema si en el momento en el que estamos 179 00:28:16,039 --> 00:28:21,019 generating those cookies, it is worth at the moment that you are logging things in that style, 180 00:28:21,019 --> 00:28:27,599 then we are going to create a state variable, then we will see if we use it or not, okay, I'm going to call 181 00:28:29,740 --> 00:28:42,170 the cons, we can call it loading 182 00:28:42,170 --> 00:28:58,640 as always we can do something like this this is going to be a use state and here I am going to put 183 00:29:02,839 --> 00:29:10,019 this I am going to do only to tell him that he is loading that we are waiting for those 184 00:29:10,019 --> 00:29:21,200 data ok then it can be good for us to do that ok then where are we here I am going to put 185 00:29:21,200 --> 00:29:40,140 the set and this I am going to leave it ok then I put it is not authenticated it has not generated 186 00:29:40,140 --> 00:29:45,079 any cookies so it cannot be authenticated the loading those data I am going to put it in 187 00:29:45,079 --> 00:29:52,220 false value and I am going to return the set user to zero, that is, in the context right now, because there will be 188 00:29:54,460 --> 00:30:07,400 nothing, this loading variable is also worth it, we are going to export it from the context, okay, okay, 189 00:30:07,400 --> 00:30:25,079 ok this is yes if that is a cookie that does not exist ok yes if it does exist what we are going to do then 190 00:30:25,079 --> 00:30:31,339 is how it can give us possible errors because we are going to go against the back-end 191 00:30:31,339 --> 00:31:01,039 in the try we are going to and we are going to say it is worth trying we are going to put a cons as 192 00:31:01,039 --> 00:31:08,480 always to collect this answer and it is here where we are going to call wait, that is why using 193 00:31:08,480 --> 00:31:13,099 this function check token that is in sync mode is worth it if I could not use this water and 194 00:31:13,099 --> 00:31:18,259 this weight because in the end it is calling everything that we have done before in the backend it is worth and 195 00:31:18,259 --> 00:31:25,140 an error can be generated then be careful with that it is worth you could not use the web and then 196 00:31:25,140 --> 00:31:33,079 put directly the joseph it is supposed that you are programmers ok after that don't do it it's 197 00:31:33,079 --> 00:31:41,579 a bit of a mess ok here we put token verification which is how we have called it and here 198 00:31:41,579 --> 00:31:50,839 lo que le voy a pasar es cookies punto vale esto lo va a recibir back en el back en va a comprobar 199 00:31:50,839 --> 00:31:57,000 todo lo que hemos hecho antes vale va a ir contra mongo va a ver si el usuario existe bueno pues es 200 00:31:57,000 --> 00:32:06,359 justo lo que lo que estamos buscando vale ahora en res vemos que no nos devuelve nada recordar 201 00:32:06,359 --> 00:32:11,680 that there were different cases, okay, then we say well in networks it has not returned anything to us 202 00:32:13,480 --> 00:32:16,359 then we are going to and we are going to say if 203 00:32:18,240 --> 00:32:24,759 three data points, that is, there is no data here, it is because you have not returned any value then 204 00:32:24,759 --> 00:32:34,140 we are going to put the set and false we are going to put the set loading 205 00:32:36,359 --> 00:32:52,079 false ok it is not loaded and a challenge and here we would finish ok now and if this is good yes 206 00:32:55,200 --> 00:33:01,880 we have been returned values ​​is worth all the user found that we had put in the part of the 207 00:33:01,880 --> 00:33:08,900 back-end user fan with the id with the username with the email that yes that he has returned it to us 208 00:33:08,900 --> 00:33:14,640 and then this is not empty the data response is not empty ok what do you want me to do with that 209 00:33:14,640 --> 00:33:23,160 well then there with that what I do want you to do is put the set and it is authenticated it is 210 00:33:23,160 --> 00:33:33,750 authenticated we tell him that you because if this has returned us data it is authenticated we have 211 00:33:33,750 --> 00:33:43,710 sent the touch is already we send it to the set and use of course that we are going to put the response of 212 00:33:43,710 --> 00:33:51,869 attack that are all the values that we have received from the back in ok which is what I insist what 213 00:33:51,869 --> 00:34:01,630 we have put with the user for a point and the user for a point user name and the user for a point and mail ok 214 00:34:01,630 --> 00:34:12,730 ok and what else can I put on it because the set long this now I put it to false because now 215 00:34:12,730 --> 00:34:18,489 I already have it all loaded ok then at a given moment I can ask for the variable 216 00:34:18,489 --> 00:34:25,070 loading then it is true or it is false and that allows me to know if it is all loaded or not ok 217 00:34:26,070 --> 00:34:31,389 with the set is autentic and that because I could also do it but well we are going to put this one 218 00:34:31,389 --> 00:34:41,570 it is also worth that this state variable is usually used, it is worth that some 219 00:34:41,570 --> 00:34:52,630 error occurs because nothing because then we are going to put the set and it is authentic false we are going to 220 00:34:52,630 --> 00:35:02,590 we are going to put the user set we tell him that there is nothing I put it in null and we are going to put the 221 00:35:02,590 --> 00:35:06,809 set the link 222 00:35:09,210 --> 00:35:18,980 to false ok and in principle I would already have that function made here that effect that is going to 223 00:35:18,980 --> 00:35:27,880 control not to take the cookies will send if the cookie exists we are going to send 224 00:35:27,880 --> 00:35:34,139 to verify token verification which is what we have generated in the back 225 00:35:34,139 --> 00:35:38,300 the information that will return me information or not that does not return me 226 00:35:38,300 --> 00:35:42,139 information because there is some kind of error that returns me the information for 227 00:35:42,139 --> 00:35:46,219 the guard that some error has occurred from the try 228 00:35:46,219 --> 00:35:52,340 because the same is worth a little all the time it is the same 229 00:35:52,340 --> 00:35:57,340 ok what else would we have to do 230 00:35:57,340 --> 00:36:05,940 because in principle we would have to take and 231 00:36:05,940 --> 00:36:28,510 we are going to take this we will have to verify it from somewhere then from where we are 232 00:36:28,510 --> 00:36:33,650 seeing or for what we are doing all this effect well to see if we can enter a 233 00:36:33,650 --> 00:36:40,889 protected route or not ok then where we were checking the protected routes 234 00:36:40,889 --> 00:36:51,090 because in the rota protected routes.jsx here is where we are asking and sauté indicate 235 00:36:51,090 --> 00:36:59,269 ok well here is where we are going to make some changes for example we have put the 236 00:36:59,269 --> 00:37:09,119 variable in loading and I want to use it ok then I am going to use it I am going to say yes 237 00:37:09,119 --> 00:37:20,809 when it was in loading to true which means that we still did not have no we had not done that 238 00:37:20,809 --> 00:37:29,829 verification against the back in ok then if loading then here I finish this function and 239 00:37:29,829 --> 00:37:47,230 return we return, for example, for example, I do not know, it occurs to me, it is worth that they put us on the page, they do it very well 240 00:37:47,230 --> 00:38:02,230 now if it is authentic and you are denied and also we are going to tell him that he does not have it in this false 241 00:38:02,230 --> 00:38:21,199 we make a name and if this is false and this is false then it takes me to this one, okay, in principle 242 00:38:21,199 --> 00:38:31,519 I think it would be okay and now we are going to try it, we come to our page 243 00:38:31,519 --> 00:38:47,429 here if I try to put the task it is finished in that it is worth it as I am not logged it sends me to the 244 00:38:47,429 --> 00:38:57,170 login it is worth well this would be fine mario santos 1 2 3 4 5 and 6 log in this is supposed to 245 00:38:57,170 --> 00:39:06,550 that we have already generated the touch more development tools here if I come to the 246 00:39:06,550 --> 00:39:21,780 application I already have touch ok there it is if here I go to task it has returned to 247 00:39:21,780 --> 00:39:46,059 he has returned us to the login impromptu so the error 248 00:39:58,809 --> 00:40:00,750 in 401 249 00:40:05,920 --> 00:40:18,449 is worth I am going to stop the video while I look to see what is happening to him and now we continue well 250 00:40:18,449 --> 00:40:28,170 is a slightly wrong error, let's see it after you are looking at it, we have in the 251 00:40:28,170 --> 00:40:36,210 js file of the client we have the sport with token verification, it is worth that it does not receive any 252 00:40:36,210 --> 00:40:41,369 input parameter, it is not like the login or register that the user receives, it is worth then from out 253 00:40:41,369 --> 00:40:45,989 context well we are already passing it here in 254 00:40:45,989 --> 00:40:51,750 token verification is not to verify if we are passing the cookies 255 00:40:51,750 --> 00:40:55,469 token but we are not using this in reality at all because then 256 00:40:55,469 --> 00:40:57,809 we are 257 00:40:58,130 --> 00:41:04,170 taking that touch of the network itself is worth then this would not be necessary 258 00:41:04,170 --> 00:41:09,449 at all then 259 00:41:09,449 --> 00:41:19,329 instead of erasing it I am going to comment on it so you always have it visible there we are going to see the code that 260 00:41:19,329 --> 00:41:28,750 seems to me that you are not seeing it no then we are going to come here now yes it is worth then this is 261 00:41:28,750 --> 00:41:37,190 what I told you that this cookies touch in reality we are passing it as an entry parameter 262 00:41:37,190 --> 00:41:42,150 token verification but in token verification I am not using it for anything so 263 00:41:42,150 --> 00:41:50,150 like we don't need to put it here for nothing good this I'm going to 264 00:41:50,150 --> 00:41:55,730 comment and I'm going to put it the same 265 00:41:56,550 --> 00:42:06,550 but without passing anything to see if it gives us some kind of error or not and I'm going to 266 00:42:06,550 --> 00:42:10,809 leave it like that in principle the rest of the code that we had put is all 267 00:42:10,809 --> 00:42:19,150 all right ok this we are going to call the route that the route we have said that it will be associated 268 00:42:19,150 --> 00:42:24,190 with the out of control of the js that is token verification and token verification as we always receive 269 00:42:24,190 --> 00:42:30,610 the network and that is, these two parameters are worth the network and the network is to answer the network is the network 270 00:42:30,610 --> 00:42:37,570 that is the request is the request ok we have the verify that because it is not returning it to us 271 00:42:37,570 --> 00:42:43,869 returns an error, it returns us that user who is going to locate it, we have done it with an arrow function 272 00:42:43,869 --> 00:42:48,730 that we could do with a normal asynchronous function, it is always worth the asynchronous because we are going to 273 00:42:48,730 --> 00:42:59,110 find the json and this is verified and this one if it works perfectly for us, it is worth and here it is 274 00:42:59,110 --> 00:43:07,349 here is where I have the problem if I put a console point here and here I put the user 275 00:43:08,349 --> 00:43:22,179 and of good that is the one that I am passing to the fine by haiti ok if I do this we are going to log in 276 00:43:22,179 --> 00:43:41,750 let's go to the page I log in 1 2 3 4 5 and 6 and it is worth if I go back to the terminal I see that I have not 277 00:43:41,750 --> 00:43:48,710 had a problem I have logged in it gives me 200 it is all right ok if I pass the task here now 278 00:43:48,710 --> 00:44:01,889 vale me está dando este indefinido y eso es que no está accediendo a él y de vale pues claro 279 00:44:03,369 --> 00:44:08,929 al no estar accediendo al y de al lanzar la consulta a la query con el fan by air y con 280 00:44:08,929 --> 00:44:13,889 este y de que es indefinido pues no me está encontrando nada y me está dando un error 281 00:44:13,889 --> 00:44:21,869 vale además es que ni siquiera es un error que no que no lo esté controlando vale porque es en la 282 00:44:21,869 --> 00:44:31,130 propia base de la propia query por eso me aparece por algún lado me aparecía 401 pero no me dice 283 00:44:31,130 --> 00:44:41,909 nada más vale entonces si yo cojo y aquí por ejemplo le ponemos voy a comentar este momento 284 00:44:41,909 --> 00:45:00,300 le pongo cons y usher fan igual a weid y usher pain vaya y si le pasó directamente el ide 285 00:45:03,119 --> 00:45:08,099 aquí copiar copiar copiar copiar si le pasó directamente este y de 286 00:45:08,099 --> 00:45:26,170 ala we are going to remove all this we are going to comment to comment no sorry to put it as a string 287 00:45:28,250 --> 00:45:34,389 if I pass this idea that is the user with whom I am logged this if it works for me if I put 288 00:45:34,389 --> 00:45:47,440 here now task ok you see that I am inside the task page it no longer returns me 289 00:45:47,440 --> 00:45:52,760 to login because because it has detected that there is the touch that I have cheated ok but we have already 290 00:45:52,760 --> 00:46:00,820 reached here and in finding the user I have passed this directly to him, it is worth that 291 00:46:00,820 --> 00:46:06,920 it is the one that is not finding me with the user and this is what has to be solved then this 292 00:46:06,920 --> 00:46:12,320 me lo está dando como un error de axios porque es la conexión desde el front con el back en pero en 293 00:46:12,320 --> 00:46:19,880 realidad es un error de no estoy pasando bien ese y de ese dato y de por eso es importante que sepáis 294 00:46:19,880 --> 00:46:26,639 utilizar bien el front y el y el baque vale por lo menos que cuando os da un tipo de error sepáis 295 00:46:26,639 --> 00:46:32,539 hacer una traza de ese error para llegar a una solución una posible solución para entonces vamos 296 00:46:32,539 --> 00:46:42,159 to see that it is returning us in and it is worth then if here we put the console 297 00:46:44,219 --> 00:46:51,980 and I do not need it I have it up there we are going to see that it is returning us in user it is worth that it 298 00:46:51,980 --> 00:46:58,659 returns us in user if there is no error in user it should be loading that idea of ​​the 299 00:46:58,659 --> 00:47:05,860 touch is worth remembering that within the touch the id is saved then to see that it returns us 300 00:47:05,860 --> 00:47:14,920 this is worth here I see it good as we are we would not need it either ok here I put 301 00:47:16,980 --> 00:47:27,179 tasks ok and then this is what this user is returning to me then I have the 302 00:47:27,179 --> 00:47:35,920 the load is worth with that idea and it is worth it and I am trying to access 303 00:47:35,920 --> 00:47:40,920 directly to this air and then this is what it does not leave me if I get here to put 304 00:47:42,300 --> 00:47:44,800 well a bit like the route not the pilot 305 00:47:47,639 --> 00:47:59,110 point there then to see now when I update here when I put the task now 306 00:47:59,110 --> 00:48:10,710 if it is returning the id that I need then yes and here I pass the user point 307 00:48:10,710 --> 00:48:23,280 to the point and it is worth this I remove it here I remove this one 308 00:48:23,280 --> 00:48:28,300 well then now if it is going to work for us we are going to see it I am going to 309 00:48:28,300 --> 00:48:38,059 go back I'm going to go back to the web page ok we have we log in mario santos 1 2 3 4 5 and 6 310 00:48:38,059 --> 00:48:59,610 log in the email is mandatory ok that's it I don't know why that email has come out is mandatory and 311 00:48:59,610 --> 00:49:08,510 if now we go to task and it leaves us without problem ok it no longer returns us to the 312 00:49:08,510 --> 00:49:19,190 login to the window to the login page ok and well this would be the error that was giving us that 313 00:49:19,190 --> 00:49:26,769 I did not know where it was ok and in the end well it is a nonsense like this but good because I have already 314 00:49:26,769 --> 00:49:34,670 thrown my little time to find it ok well already in the next video what we are going to start 315 00:49:34,670 --> 00:49:40,349 do is the whole issue of tasks but well I think that the most important thing is already there 316 00:49:41,849 --> 00:49:44,530 good a greeting bye guys