Angular : Implementing Token and Role Based Authentication Using JWT | AuthGuard and Interceptor

Angular : Implementing Token and Role Based Authentication Using JWT | AuthGuard and Interceptor

Learn Programming Yourself

2 года назад

74,235 Просмотров

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


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

@gayathrimachavarapu8448
@gayathrimachavarapu8448 - 30.10.2023 11:49

Hai sir I am getting "JWT strings must contain exactly 2 period characters.Found:0 " in backend while logging in

Ответить
@coba4036
@coba4036 - 11.10.2023 18:19

pls never zoom again and less fucking add

Ответить
@kalpanaguntoju1939
@kalpanaguntoju1939 - 31.07.2023 15:35

Thanks a lot for sharing this video.

Ответить
@RN-jo8zt
@RN-jo8zt - 06.07.2023 15:07

Too Nice
for real project where we are storing token?

Ответить
@lolmamon
@lolmamon - 03.07.2023 08:23

Very useful tutorial and channel, friend!

Ответить
@chahrazedbenazaiez3284
@chahrazedbenazaiez3284 - 22.06.2023 18:46

Thank you very much, i really appreciate the detailed explanation.

Ответить
@rakeshpatil9253
@rakeshpatil9253 - 20.06.2023 23:12

Hi bro canActivate is deprecated in angular so can you give me new code for that one

Ответить
@bustros8210
@bustros8210 - 09.06.2023 04:29

@Learn Programming Yourself - I am having a small issue; my role is coming back as an empty array; what should I do ?

Ответить
@rahul6839
@rahul6839 - 23.05.2023 15:08

Can I get your email id?

Ответить
@NEOCODE-ATLAST
@NEOCODE-ATLAST - 16.05.2023 11:20

Hello ,
I have one problem i am getting the roles array blank if the api was fired from frontend, but from postman the response is Ok. can u help ?

Ответить
@lyricsmusic3839
@lyricsmusic3839 - 16.05.2023 05:51

Hiii thank you so much for these tutorials they really help. If you don't mind i added an angular component register new agent but i didn't how to connect it with the back seeing that it needs a token to have access to the back. Please help

Ответить
@musthafakareechiyil1874
@musthafakareechiyil1874 - 12.05.2023 13:49

getting error (implements CanActivate)'CanActivate' is deprecated.ts(6385)
index.d.ts(301, 4): The declaration was marked as deprecated here. i am using Angular 16.0.1 is this beacuse of version cange?

Ответить
@tekiesan
@tekiesan - 04.05.2023 13:36

Nice tutorial on the topic and very detailed explanation. Thanks very much for sharing the info

Ответить
@PhanTanThangTH
@PhanTanThangTH - 18.04.2023 17:53

Thank you so much, I really really appreciate that, keep up bro :)

Ответить
@shyamprasanth1042
@shyamprasanth1042 - 07.04.2023 09:11

export class UserAuthService {

constructor() {}

public setRoles (roles: []){


localStorage.setIt

}

public getRoles(){

return JSON.parse(localStorage.getItem("roles));


public setToken(jwtToken:string) {


localStorage.setItem("jutToken", jwtToken);

}

public getToken(): string{ return localStorage.getItem("jutToken");

}

public clear(){

localStorage.clear();

}


public isLoggedIn(){

return this.getRoles ()&& this.getToken();

It shows this error on compile time
Argument of type 'string | null' is not assignable to parameter of type 'string'. Type 'null' is not assignable to type 'string'. ts(2345)
On user-auth.service
Please tell me how to rectify it

Ответить
@pratikmadekar5728
@pratikmadekar5728 - 13.03.2023 19:50

Thanks for sharing the knowledge from this videos I solved my many issues also can you please provide a video on storing the user data into session instead of storing the data into local storage

Ответить
@drownzzy
@drownzzy - 01.02.2023 19:41

When implementing all this, I get a 403 error on the pages (components) where I don't want people to be logged in.
What could be the cause ?
The header "No-Auth" is not set when people are not logged in.

Ответить
@muhammadsalah3981
@muhammadsalah3981 - 25.01.2023 14:46

Thanks for the hard work

Ответить
@avanishkumar1689
@avanishkumar1689 - 17.01.2023 22:35

How to fix cors error ?

Ответить
@JhanaviRathod-zi4yk
@JhanaviRathod-zi4yk - 17.01.2023 18:21

very useful I am beginner and finally I am able to do thank you so much

Ответить
@srikarpuligilla5724
@srikarpuligilla5724 - 10.01.2023 17:51

can you say the other way to save the user data other than local storage.

Ответить
@dhanshrijangam
@dhanshrijangam - 08.01.2023 13:19

Could you please explain implementation for shared services or Cookies or Sessions to store data instead of local storage?

Ответить
@haithammuhamad7892
@haithammuhamad7892 - 19.12.2022 10:43

please can tell me what is the version of node js you used in this project

Ответить
@RohitKumar-dz8dh
@RohitKumar-dz8dh - 19.11.2022 17:26

Thank you so much sir for explaining each and every concepts. Now because of you I can build my own projects 🙏🙏.

Ответить
@nirodhasandanuwan5488
@nirodhasandanuwan5488 - 15.11.2022 17:12

your genius buddy thank you so much

Ответить
@selamawikahsai5664
@selamawikahsai5664 - 10.11.2022 04:08

Thankyou for the hardwork. I have one question though,the part where you used the *ngIf to hide and show the User and Admin dashboard is not really working for me.when I logged in the dashboard for specific role was supposed to be visible on the nav bar,unfortanatly , only the Home and logout button are visible when i logged in as User or Admin.
any suggestion why it's doing that?

Ответить
@selamawikahsai5664
@selamawikahsai5664 - 06.11.2022 04:35

That's really greate content and presentation,thanks for the hardworking you put on.
I have one request, I was wondering on how we can call any CRUD operation endpoint from the user.component.ts and user.service.ts. it would be much appriciated if you could give me one example on how to implement any CRUD operation enpoint with Token and Role Based Authentication Using JWT.
thanks in advance!!

Ответить
@mariyakerfati6947
@mariyakerfati6947 - 05.11.2022 22:54

I have a question please , can we use JWT with oneTOMany relation between User entity and Role entity instead of manytomany ?

Ответить
@anantsoni6335
@anantsoni6335 - 27.10.2022 10:45

Hii great video but
public roleMatch(allowedRoles:any): boolean{
let isMatch = false;
const userRoles: any = this.userAuthService.getRoles();
if (userRoles != null && userRoles) {
for (let i = 0; i < userRoles.length; i++) {
for (let j = 0; j < allowedRoles.length; j++) {
if (userRoles[i].roleName === allowedRoles[j]) {
isMatch = true;
return isMatch;
} else {
return isMatch;
}
}
}
}
}
This boolean gives me an error as the return value is unreachable.
Will you please tell me the exact issue?

Ответить
@jovanjovanovic5764
@jovanjovanovic5764 - 17.10.2022 20:17

subscribe is now deprecated what to use now

Ответить
@mohammedajazquadri7869
@mohammedajazquadri7869 - 17.10.2022 08:57

Iam not getting token in ui what to do sir?

Ответить
@hc7637
@hc7637 - 10.10.2022 01:13

Jwt Refresh pls 😢

Ответить
@harshtyagi6756
@harshtyagi6756 - 22.09.2022 18:33

Hey, Thanks for the hard work you have done to make this video. It helps me to give a lot of knowledge which I really want to get.

Ответить
@gusmas1991
@gusmas1991 - 14.09.2022 23:45

thank you for the video. i am new to angular and jwt authorization and yout video is a huge help. i need a CRUD for managing the video. Is there any video that i could add it to this current jwt video? Thanks

Ответить
@oumaimalaboudi1877
@oumaimalaboudi1877 - 10.09.2022 16:14

thanks for this amazing tutorial .

Ответить
@zjavierar2430
@zjavierar2430 - 04.08.2022 10:09

There's a any possibility that if you deploy this application, somebody can have access to that function of IsMatch, and just put randomly any value like Admin?, if the people is an User for example, like one vulnerability.

Ответить
@prasannapras7852
@prasannapras7852 - 15.07.2022 09:35

How to create admin role credentials dynamically, not writing manually in the code

Ответить
@ramielkamel473
@ramielkamel473 - 11.07.2022 11:48

public roleMatch(allowedRoles): boolean , im getting an error Function lacks ending return statement and return type does not include 'undefined'.

Ответить
@nicolaslouna4105
@nicolaslouna4105 - 08.07.2022 21:33

are u have he source code in git

Ответить
@maneshipocrates2264
@maneshipocrates2264 - 08.07.2022 15:18

This video need more views and it so so simplified. Even though I just dabbled into front end development. THANK YOU!

Ответить