Role-Based Authentication in React (Complete Tutorial)

Role-Based Authentication in React (Complete Tutorial)

Cosden Solutions

6 месяцев назад

47,751 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@Lykkos-321
@Lykkos-321 - 28.08.2024 19:48

most cleanest react channel!! I needed this!!

Ответить
@Solo_playz
@Solo_playz - 28.08.2024 19:53

Way to 100k Lets goo you deserve more brother .... 🫡

Ответить
@mohamedsalimbensalem6118
@mohamedsalimbensalem6118 - 28.08.2024 19:54

Can you make a video about casel

Ответить
@roman9266
@roman9266 - 28.08.2024 20:33

exactly what I needed. Thank you!🤩

Ответить
@rohansachdeva627
@rohansachdeva627 - 28.08.2024 20:35

How to handle situation where i need to show a different component on a page depending on the role type? Do you have a clean solution for that

Ответить
@Jesus901
@Jesus901 - 28.08.2024 20:50

I love your videos!

Ответить
@Rohan-hx7ry
@Rohan-hx7ry - 28.08.2024 21:20

How do i preview react website on phone when it's under development... Plz reply

Ответить
@dariorey8092
@dariorey8092 - 28.08.2024 21:33

justo lo que estoy necesitando!!

Ответить
@TrilochanSatapathy
@TrilochanSatapathy - 28.08.2024 21:43

Repo ???

Ответить
@randhir2588
@randhir2588 - 28.08.2024 21:48

source code missing

Ответить
@okadz7037
@okadz7037 - 28.08.2024 23:34

Ty great tutorial 👑, i have a question, is the backend check role safer then this client side check, for example: in nextjs i check in the middleware or in the rsc pages, and redirect from there

Ответить
@jacquelynecarmen
@jacquelynecarmen - 28.08.2024 23:56

❤❤

Ответить
@mohamedyamani8502
@mohamedyamani8502 - 29.08.2024 01:00

nice video!

I implemented this once, but arrived at a situation I didn't like. In order to send the JWT with each request, I'd use interceptors for example, and since the accessToken is passed through context, the fetcher instance must also be a hook in order to access the token. This snowballs to each request you try to make, which must end up a hook.

how do you deal with this?

Ответить
@gauravbawa5609
@gauravbawa5609 - 29.08.2024 02:12

once again a great content and a very informative video, thank you so much

Ответить
@lil_nach
@lil_nach - 29.08.2024 02:58

I think you mean role based authorization right? The distinction between authentication and authorization is important

Ответить
@muhammedsahad1612
@muhammedsahad1612 - 29.08.2024 07:51

Best Channel for React

Ответить
@buddytech7775
@buddytech7775 - 29.08.2024 08:40

Next video on context api with authentication with cookies, cookies store token user details with axios only authentication user access dashboard with protected routes waiting for your response (⁠◔⁠‿⁠◔⁠)

Ответить
@kalideb-y3y
@kalideb-y3y - 29.08.2024 09:10

isn't it bad when creating variable name same exactly as type name like the const AuthContext and type AuthContext? I am thinking to just lowercase the const like authContext, cause I am kinda confused when I see them

Ответить
@himanshuchavda9887
@himanshuchavda9887 - 29.08.2024 09:15

Next authentication in next.js

Ответить
@kalideb-y3y
@kalideb-y3y - 29.08.2024 09:28

can't this client codes be edited and then have access the protected route?

Ответить
@BuddyTech-w2h
@BuddyTech-w2h - 29.08.2024 10:37

use context api with authentication with cookies, with axios only authentication user access dashboard with protected routes waiting for your response

Ответить
@tomasburian6550
@tomasburian6550 - 29.08.2024 12:10

Thanks for this. Auth has been my biggest weakness for the longest time.

Ответить
@Thomas-zr9uw
@Thomas-zr9uw - 29.08.2024 12:52

You really create the best content, real scenario's with best practices. Good reason for your channel to grow so well.

Ответить
@CLeovison
@CLeovison - 29.08.2024 14:53

Hi kosden, will it be possible in the future that you will make a video about implementing seo in react? Because that will be a really great great help, thank you so much

Ответить
@Shelton_fr
@Shelton_fr - 29.08.2024 14:56

The best

Ответить
@wassimabdennadher2715
@wassimabdennadher2715 - 29.08.2024 17:28

Great Job ! Can you please manage roles and authentication with redux

Ответить
@codewithsanjay
@codewithsanjay - 29.08.2024 21:36

Great video, could you please teach us RBAC in next.js

Ответить
@jofay91
@jofay91 - 29.08.2024 22:24

so happy i found your channel! great content as always!

Ответить
@pelumini
@pelumini - 30.08.2024 10:28

Great content, thanks

Ответить
@dhruvverma1001
@dhruvverma1001 - 30.08.2024 13:18

Need "Project Next"

Ответить
@MrJettann
@MrJettann - 30.08.2024 22:07

This is bad implementation of authentication, there are no cookies, access or refresh tokens, so it simply makes requests on every page refresh

Ответить
@bestformspielt
@bestformspielt - 30.08.2024 22:31

I really love your channel and your very clean and simple way of writing code. This is the first time you took a slightly bad shortcut by using sentinel values for your context. Saying that "undefined" means one thing and "null" means another makes the code hard to read and reason about. A better way in my opinion would be an additional attribute in your context called "authState" which is an enum containing "pending", "authenticated" etc. This would make it way more obvious and intuitive.
This is of course nit-picking. I still think your videos are the best react content there is. Thanks for making them. :)

Ответить
@AbdulMajeed-lj3zi
@AbdulMajeed-lj3zi - 01.09.2024 16:38

Pleae make one video about Casal (Role Base Authentication) library

Ответить
@grugbrain
@grugbrain - 01.09.2024 18:40

Very clear implementation. 🥰

Ответить
@kevinngugi6120
@kevinngugi6120 - 01.09.2024 23:37

when my lead engineer sees me try to authenticate users on the client🤣🤣🤣 i might as well fire myself

Ответить
@pinoyolea
@pinoyolea - 02.09.2024 10:04

You mean Role based Authorization?

Ответить
@sunny7268
@sunny7268 - 02.09.2024 11:06

can you cover jotai lib, it is great and to bad many do not know it is even exist.

Ответить
@kevinchen9799
@kevinchen9799 - 04.09.2024 15:52

Good video. But the title is wrong. It should be Authentication and Role based Authorization. Authentication is verifying if you are a valid user or not. Then comes Authorization. That is how they are defined in Computer Science

Ответить
@ritankarbhattacharjee7661
@ritankarbhattacharjee7661 - 09.09.2024 09:51

The video was awesome 👍. This is a per component based application right, I wanted to know that if we wanted to protect a complete route like /staff and its children /staff/profile, /staff/edit-profiles etc at once, then how will we do it? For projects where there might be many components that might need protection adding ProtectedRouteComponent like this may become a laborious task.

Ответить
@pedrosilva2313
@pedrosilva2313 - 13.09.2024 21:14

I'd recommend you to use the <Outlet /> component from react-router-dom since we can add multiple routes to the same ProtectedRoute instead of adding multiple ProtectedRoute for each different route.

Ответить
@Atul_25
@Atul_25 - 26.09.2024 10:51

This is such a peaceful video.

Even your voice sounds ASMR.

I badly needed it.
I just also saw your authentication handling video.

I can now combine both and reap best results.

This day have been won 😸🤩🥹.

Thanks a lot

Ответить
@elabinnovations
@elabinnovations - 13.10.2024 17:34

Thanks, but I'm stuck with GraphQL JWT auth. I'm using codegen and hooks for mutations and queries.

Ответить
@thelayel
@thelayel - 22.10.2024 01:57

great

Ответить
@pavlevelickovic2995
@pavlevelickovic2995 - 24.10.2024 18:32

I love this implementations but i have one BIG question. The way you wrote this all login logic is in AuthProvider(including fetch itself) and although this look clean i run into a problem when i tried to make Login page. In order to show potential errors or loading state when user tries to log in i needed login fetch logic in my Login page component however you put that logic inside AuthProvider. I though of moving login fetch from AuthProvider to Login component and leaving just setCurrentUser and setAuthToken to AuthProvider. This way i will be able to monitor fetch state (show errors and loading state to user). Is this valid solution and if not please give me some advise.

Ответить
@DShpak27
@DShpak27 - 05.11.2024 00:35

Thanks for You work! But there is an error with statuses, in particular undefined in user. The author automatically fetches data through the use effect, in fact you receive authorization data only after sending the authorization form. It's bad that he did not simulate this in the example. It would have been a different matter, and so many will still have the task of really correctly processing authorization statuses in a protected route.

Ответить
@challengerScat
@challengerScat - 13.11.2024 15:25

nice tut but this is insufficient cuz when handling multiple routes the currentUser goes back to null therefore you lose the ability to check for roles however you can use localStorage as an alternative to store the desired roles and then retrieve it when needed

Ответить
@HANWINHUOR
@HANWINHUOR - 17.12.2024 07:21

From Cambodia . I love your video so much . your channel help me a lot . thank u man

Ответить
@ramonrasheed3059
@ramonrasheed3059 - 23.01.2025 17:52

Great Video

Ответить
@thiagomasseno2550
@thiagomasseno2550 - 16.02.2025 04:56

concerteza eu vou maratonar os videos deste canal

Ответить