Тёмный

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

Learn Programming Yourself
Подписаться 14 тыс.
Просмотров 74 тыс.
50% 1

Let's understand, how to implement jwt token and role based authentication mechanism in angular using auth guard and interceptors. In the previous session, we created spring boot app to generate and validate the jwt token. So now we are going to create an angular application to make use of those services.
In this session, I have discussed following points.
1. How to implement jwt token and role based authentication mechanism in angular?
2. How to implement auth guard in angular?
3. How to use jwt token in angular?
Disclaimer - The music/audio used(if any) in this video is not a property of "Learn Programming Yourself". All credit goes to owners of respective music/audio. This music/audio is not prone to any "Copyright Strikes".
#angularjwt #angularauthguard
------------------------------------------------------------------------------------------
Here're links to git repo
1. jwt-youtube (Spring Boot)
github.com/team-learn-program...
2. jwt-youtube-ui (Angular)
github.com/team-learn-program...
--------- Links to my other FREE courses. ---------
▶ Java 8 Full Course - • Java 8
▶ JDBC Full Course - • 1. Introduction to JDB...
▶ Microsoft Cognitive Services Course - • Computer Vision + Angu...
▶ JWT in Spring Boot and Angular - • How to download and in...
▶ CRUD Operations in Spring Boot and Angular (Full Stack) - • 1. Angular 16 and Spri...
▶ Console Based Banking Application Using Java - • Developing Console Bas...
▶ E-Commerce Application Development Using Angular and Spring Boot (Full Stack) - • 1. Developing E-Commer...

Опубликовано:

 

21 июл 2021

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 210   
@richakumari575
@richakumari575 2 года назад
I felt this is the most detailed video which does not need any pre or post go through of other video to understand the topic .Thanks a lot for sharing this complete info.
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
Thanks a lot Richa
@BK-nb9or
@BK-nb9or 3 года назад
Although your previous version of this tutorial was very helpful already, thanks for this update!
@LearnProgrammingYourself
@LearnProgrammingYourself 3 года назад
Thank BK.
@whereiswaldo7743
@whereiswaldo7743 2 года назад
This is probably the best tutorial about jwt and angular.
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
Thanks a lot
@RohitKumar-dz8dh
@RohitKumar-dz8dh Год назад
Thank you so much sir for explaining each and every concepts. Now because of you I can build my own projects 🙏🙏.
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
Nice to hear this
@hendrymwamburi2744
@hendrymwamburi2744 2 года назад
Thanks alot for sharing the knowledge you delivered the content in a simpler way
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
Glad it was helpful!
@harshtyagi6756
@harshtyagi6756 Год назад
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.
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
Glad it was helpful!
@pavanprashanth5704
@pavanprashanth5704 Месяц назад
Thank you for making this video
@chahrazedbenazaiez3284
@chahrazedbenazaiez3284 Год назад
Thank you very much, i really appreciate the detailed explanation.
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
Thanks a lot
@GiovanniGando
@GiovanniGando 4 месяца назад
Thank you, this was really helpful and well explained.
@ernestmn
@ernestmn 2 года назад
Thank you for the video, it's really helpful 👏
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
Thanks a lot
@PhanTanThangTH
@PhanTanThangTH Год назад
Thank you so much, I really really appreciate that, keep up bro :)
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
Glad I could help
@maneshipocrates2264
@maneshipocrates2264 2 года назад
This video need more views and it so so simplified. Even though I just dabbled into front end development. THANK YOU!
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
Thanks a lot
@maneshipocrates2264
@maneshipocrates2264 2 года назад
@@LearnProgrammingYourself No worries, But it seems WebMvcConfigurerAdapter is deprecated in spring boot 2.7.0+!
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
yes it's deprecated now.
@maneshipocrates2264
@maneshipocrates2264 2 года назад
@@LearnProgrammingYourself U can use Blockman in vscode. It simplifies checking brackets etc. Good extension.
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
Thanks a lot
@alljobcircularpreparation3163
@alljobcircularpreparation3163 6 месяцев назад
Thank You So Much Brother ,Just Awesome
@LearnProgrammingYourself
@LearnProgrammingYourself 5 месяцев назад
So nice of you
@tekiesan
@tekiesan Год назад
Nice tutorial on the topic and very detailed explanation. Thanks very much for sharing the info
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
Thanks a lot.
@kalpanaguntoju1939
@kalpanaguntoju1939 11 месяцев назад
Thanks a lot for sharing this video.
@LearnProgrammingYourself
@LearnProgrammingYourself 11 месяцев назад
Thanks a lot
@lolmamon
@lolmamon Год назад
Very useful tutorial and channel, friend!
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
Thanks a lot😊
@muhammadsalah3981
@muhammadsalah3981 Год назад
Thanks for the hard work
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
Thanks a lot
@oumaimalaboudi1877
@oumaimalaboudi1877 Год назад
thanks for this amazing tutorial .
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
Thanks a lot
@nadiakhlif4214
@nadiakhlif4214 2 года назад
thank you it is very useful , keep going
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
Glad it was helpful!
@pegeb987
@pegeb987 Месяц назад
Hey champ u drop this 👑👑❤️❤️❤️
@nirodhasandanuwan5488
@nirodhasandanuwan5488 Год назад
your genius buddy thank you so much
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
Thanks a lot
@freeman5453
@freeman5453 2 года назад
thaaaaanks a lot, very helpful
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
Glad it helped!
@Youssef-jl7
@Youssef-jl7 2 месяца назад
Merci Mr
@rizkyyulianto54
@rizkyyulianto54 Год назад
if you get blank roles at 1:13:59 you should go back to 1:13:29 and change response.user.role to response.user.roles or whatever keys you assigned for user role in postman when you hit /authenticate
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
Thanks for adding it
@rizkyyulianto54
@rizkyyulianto54 Год назад
@@LearnProgrammingYourself no problem
@mohammadtalha8882
@mohammadtalha8882 11 месяцев назад
Hi I've been following your tutorials and they are really helpful. Just wanted to let you know that in this implementation of jwt, When you implement the "roleMatch(allowedRoles)" at 1:29:16 , the for loop ends prematurely after single iteration since we have returned isMatch in "else" block. Please check the foor loop. I corrected it myself by debugging. Instead of writing "else" block atline 33, you have to end the if block without else block and after exiting the first "if* block (which is at line 27), you have to return isMatch at line 38 when first "if" block ends. The wrong loop works if we have only one role assigned in router a api endpoint, but if we have multiple roles in array in our router for an api then the loop checks only for the first role provided in the router and the loop ends.
@LearnProgrammingYourself
@LearnProgrammingYourself 11 месяцев назад
Great observation. I will check and correct this. Thanks a lot
@pratikmadekar5728
@pratikmadekar5728 Год назад
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
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
Yes will do this
@philjohnston6442
@philjohnston6442 Год назад
Absolutely fantastic video and explanation on front-end e-commerce in Angular with JWT authentication. I read that local storage and sessions are bad practice to store tokens as is open for XSS attacks. It is best practice to store tokens in HTTPOnly cookie. Can you please show how to do this in your app?
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
Yes noted your point
@fighter9953
@fighter9953 2 года назад
Hi, such a helpful tuto But i want to disable the security configuration in the backend and let it working in frontend, i want to test my backend without authentication any help? Thanks in advance
@marypaul9627
@marypaul9627 22 дня назад
About to watch it I already liked your last Video I watched, which one do I need to watch before this one?
@selamawikahsai5664
@selamawikahsai5664 Год назад
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!!
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
Yes will try to share this
@rahathasan5971
@rahathasan5971 3 месяца назад
I have a question if I provide authentication in spring boot do I need to do it in angular?
@hc7637
@hc7637 2 года назад
Hey nice tutorial thanks a lot. Can you do refresh token tutorial as well?
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
Yes sure I will do that
@lyricsmusic3839
@lyricsmusic3839 Год назад
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
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
please check my e-commerce application development series. you will get mist of the answers
@RN-jo8zt
@RN-jo8zt Год назад
Too Nice for real project where we are storing token?
@LearnProgrammingYourself
@LearnProgrammingYourself 11 месяцев назад
There are lots of options and they are subjective to different scenarios
@gusmas1991
@gusmas1991 Год назад
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
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
I am not sure about your exact requirement's. But you can my Creating Student Dashboard Playlist ones.
@gayathrimachavarapu
@gayathrimachavarapu 8 месяцев назад
Hai sir I am getting "JWT strings must contain exactly 2 period characters.Found:0 " in backend while logging in
@mohameddhia770
@mohameddhia770 2 года назад
Arigato gozaimasu
@kiransuryawanshi4904
@kiransuryawanshi4904 7 месяцев назад
Error-- LocalStorage is not defined at getRoles and getToken. Help me to solve this
@dhanshrijangam
@dhanshrijangam Год назад
Could you please explain implementation for shared services or Cookies or Sessions to store data instead of local storage?
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
Yes. Noted. Surely will try to explain it.
@zjavierar2430
@zjavierar2430 Год назад
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.
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
Once application is deployed no one can access files as the project is bundled in one file.
@mariyakerfati6947
@mariyakerfati6947 Год назад
I have a question please , can we use JWT with oneTOMany relation between User entity and Role entity instead of manytomany ?
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
Yes we can use any mapping
@chamith256
@chamith256 2 года назад
1:11:00 I'm parsing the role array in the token. what is the change I should do to use this method?
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
I think there is no any change required as we are parsing role into token itself. If you visit to JWT token site and try to decrypt your token then you will see role in it.
@ramielkamel473
@ramielkamel473 2 года назад
public roleMatch(allowedRoles): boolean , im getting an error Function lacks ending return statement and return type does not include 'undefined'.
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
I hope it's resolved now. I know it's very long duration I took to reply.
@selamawikahsai5664
@selamawikahsai5664 Год назад
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?
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
I think you can check the conditions very closely. We have used ! (Not operator) in some conditions as well
@selamawikahsai5664
@selamawikahsai5664 Год назад
@@LearnProgrammingYourself thanks for the reply,I have already solved it.
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
Great
@ketancharwad6702
@ketancharwad6702 Год назад
@@selamawikahsai5664 how you solved this plz let me know
@musthafakareechiyil1874
@musthafakareechiyil1874 Год назад
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?
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
need to check
@srikarpuligilla5724
@srikarpuligilla5724 Год назад
can you say the other way to save the user data other than local storage.
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
Yes will try to cover it soon.
@drownzzy
@drownzzy Год назад
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.
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
need to check in interceptor file.
@aayushisolanki6969
@aayushisolanki6969 7 месяцев назад
​@@LearnProgrammingYourself Sir,I am also getting the same error, how do I solve it?" "I checked the code and it is exactly the same as my file."
@krishnendughosh2368
@krishnendughosh2368 2 года назад
At 01:06:57 it says "Argument of type 'string | null' is not assignable to parameter of type 'string'. Type 'null' is not assignable to type 'string'" as the localStorage.getItem('roles'); may also return null values. please tell me the solution.
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
I need to check the code to give the solution.
@nadiakhlif4214
@nadiakhlif4214 2 года назад
the solution is adding this : return JSON.parse(localStorage.getItem('roles')|| 'null' || '{}');
@okashaabdulrasheed7956
@okashaabdulrasheed7956 Год назад
@@nadiakhlif4214 Thanks
@haithammuhamad7892
@haithammuhamad7892 Год назад
please can tell me what is the version of node js you used in this project
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
UI: Angular 10 npm 6.14.13
@NEOCODE-ATLAST
@NEOCODE-ATLAST Год назад
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 ?
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
need to check
@user-fd2ej1ht9u
@user-fd2ej1ht9u 6 месяцев назад
the ui is not working can you help sir?? it needs update
@manojtiwari3071
@manojtiwari3071 2 года назад
can you do through Session and can you tell if the user have multipal role then how can we do it Will be more helpful for me
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
Thanks a lot for suggestions. Will try to create video on the same topic
@manojtiwari3071
@manojtiwari3071 2 года назад
@@LearnProgrammingYourself when you upload???
@musthafakareechiyil1874
@musthafakareechiyil1874 Год назад
@@LearnProgrammingYourself if you have created video can you share link
@kaushalkarkar
@kaushalkarkar Год назад
DOMException: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': 'No Auth' is not a valid HTTP header field name. this error coming
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
Need to check code
@benhamedjawher9970
@benhamedjawher9970 2 года назад
does this project goes with Angular version 9 ?thanks!
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
I think yes. But i will confirm and let you know
@fighter9953
@fighter9953 2 года назад
Hi, both videos Were very helpful with good explanation, I congratulate you and i appreciate your effort, the only problem i had was when i implemented the authgard i couldn’t login again i got 401 error , can you help me and thanks for this
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
Thanks a lot. You can connect with me in case if you need help over google meet
@fighter9953
@fighter9953 2 года назад
@@LearnProgrammingYourself thank you it will be a very rich experience
@fighter9953
@fighter9953 2 года назад
I have arrived to solve the problem, it was very easy in auth.interceptor.ts Instead of using acute accent in ‘Bearer ${token}’ i used comma. again this tuto is the best treating token and role based in angular+spring boot hope to see other tuto from you
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
Thanks a lot for appreciation
@aayushisolanki6969
@aayushisolanki6969 7 месяцев назад
Actually,I am also getting the same error, how do I solve it?"
@prasannapras7852
@prasannapras7852 2 года назад
How to create admin role credentials dynamically, not writing manually in the code
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
You just need to create an endpoint to register an admin
@bustros8210
@bustros8210 Год назад
@Learn Programming Yourself - I am having a small issue; my role is coming back as an empty array; what should I do ?
@NEOCODE-ATLAST
@NEOCODE-ATLAST Год назад
You must be getting the Token but the roles array is empty is that right ?
@bustros8210
@bustros8210 Год назад
@@NEOCODE-ATLAST yes that is exactly what is happening. To go around this I created a column User_role in my user database
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
need to check
@rizkyyulianto54
@rizkyyulianto54 Год назад
@@bustros8210 so you change the user role column from the join table?
@mohamedbizarre1
@mohamedbizarre1 2 года назад
i would love to see tutorial on storing token in onlyhttp cookies
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
Yup great suggestion. We will do that
@krpv12
@krpv12 2 года назад
Please teach angular also 🙏
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
Yes. Will surely create a new series
@rakeshpatil9253
@rakeshpatil9253 Год назад
Hi bro canActivate is deprecated in angular so can you give me new code for that one
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
Will check and work
@ahmedyassinzouaoui8257
@ahmedyassinzouaoui8257 6 месяцев назад
the problem is JWTokens implementation isnt working for me and i couldnt solve that at all ...
@LearnProgrammingYourself
@LearnProgrammingYourself 6 месяцев назад
What is the problem that you are facing??
@ahmedyassinzouaoui8257
@ahmedyassinzouaoui8257 6 месяцев назад
@@LearnProgrammingYourself WebSecurityConfigurerAdapter is deprecated so i had to change it with securityFilterChain and from that things got too complicated for me i always get that my spring project miss some beans or circular dependency issue and i couldnt solve it at all ...
@sunlolafakolujo5550
@sunlolafakolujo5550 Год назад
Dear Friend, Thank you for the effort you put into the subject video on your RU-vid channel for others to learn. God bless you. I was trying to implement the same, but I encountered the error attached below in the UserAuthService with the getters (Argument of type 'string | null' is not assignable to parameter of type 'string'. Type 'null' is not assignable to type 'string'.ts(2345)). I will appreciate it if you can throw more light on the error and point me in the right direction. Regards, Emmanuel
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
Can you please try to use code in this way. this.currentUser = JSON.parse(localStorage.getItem('currentUser') || '{}'); just change name 'currentUser' and keep it as per my code.
@sunlolafakolujo5550
@sunlolafakolujo5550 Год назад
@@LearnProgrammingYourself Thank you it worked. More grace friend.
@sunlolafakolujo5550
@sunlolafakolujo5550 Год назад
Dear friend, Pls, is it a must to return role(s) with JwtResponseToken(/login) class at the back-end for a user (either admin or user) to have access to their authorized APIs at the front-end?
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
Yes it is.
@sunlolafakolujo5550
@sunlolafakolujo5550 Год назад
@@LearnProgrammingYourself Thank you.
@zainabalfanah6719
@zainabalfanah6719 Год назад
Sir i have error in addFilterBefore in type HttpSecurity is not applicable for arguments (JwtRequestFIlter, class
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
Need to check code you wrote
@veerachinnu5939
@veerachinnu5939 Год назад
pom.xml change spring boot version 2.4.5
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
Great. Thanks for your help here.
@veerachinnu5939
@veerachinnu5939 Год назад
Hi sir please upload more project using spring boot angular like inventory Management system
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
@@veerachinnu5939 Yes will consider uploading some similar projects.
@phylaxcool
@phylaxcool 2 года назад
Nice tutorial, however it is not complete without refresh token
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
Thanks a lot
@aeshabhavsar2704
@aeshabhavsar2704 2 года назад
Hello nice work but i did not get user in response means in console response user is null but jwttoken i got...how can i get user ????
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
Make sure you are adding you user to JwtResponse class while returning
@aeshabhavsar2704
@aeshabhavsar2704 2 года назад
@@LearnProgrammingYourself yes thanks but now it gives error in console that "blocked by cors policy"...how can i get rid of it??
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
Just go corsconfiguration class and put @bean annotation on the class
@aeshabhavsar2704
@aeshabhavsar2704 2 года назад
@@LearnProgrammingYourself hey have put already it but not working
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
Ohh. I may need to look into code to suggest you something
@mohammedajazquadri7869
@mohammedajazquadri7869 Год назад
Iam not getting token in ui what to do sir?
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
I may need to check the code first.
@ninjatechstudio
@ninjatechstudio 2 года назад
Please Provide Video dynamice created role access not static
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
Yup I will create soon.
@akhilthammishetty3097
@akhilthammishetty3097 2 года назад
I'm getting HttpErrorResponse 403 when clicked on login please resolve my issue?
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
Can you check other comments. Solution is provided there
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
Thanks a lot
@fighter9953
@fighter9953 2 года назад
@@mohnishbonde4463 how did u solve it?
@mohnishbhonde7602
@mohnishbhonde7602 2 года назад
@@fighter9953 I was getting 401 error, and somebody in another comment told to paste that code
@fighter9953
@fighter9953 2 года назад
@@mohnishbhonde7602 which code?
@avanishkumar1689
@avanishkumar1689 Год назад
How to fix cors error ?
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
At the backend you need to configure your cors
@khanh7817
@khanh7817 Год назад
1:24:16 Hi guys, in this time my localstorage was clear but my Ui didnt display the login button, please help
@khanh7817
@khanh7817 Год назад
how can i show you this, pls help
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
You can connect with me over gmeet
@khanh7817
@khanh7817 Год назад
@@LearnProgrammingYourself where is the link gmeet?
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
@@khanh7817 if you share me you email id here then will create meeting
@khanh7817
@khanh7817 Год назад
@@LearnProgrammingYourself Hi Mr.LearnProgrammingYourself, I think solved this problemb , thanks for caring me
@thomasamathew4058
@thomasamathew4058 Год назад
1:26:32
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
thanks for watching
@nicolaslouna4105
@nicolaslouna4105 2 года назад
are u have he source code in git
@LearnProgrammingYourself
@LearnProgrammingYourself 2 года назад
Yes. Link is in description box
@hc7637
@hc7637 Год назад
Jwt Refresh pls 😢
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
Surely we will work on this.
@jovanjovanovic5764
@jovanjovanovic5764 Год назад
subscribe is now deprecated what to use now
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
I will check on this. and will share one example with you.
@Zoxxxyde
@Zoxxxyde Год назад
​@@LearnProgrammingYourselfI think you have to use rxjs
@Zoxxxyde
@Zoxxxyde Год назад
login() { this.userService.login(this.mainForm.value).pipe( tap(saved => { if (saved) { console.log(saved) } else { console.log("error"); }; }) ).subscribe();
@marieledecarvalho6378
@marieledecarvalho6378 2 месяца назад
does anybody know how to solve this error while importing FormsModule (43:52)? 'FormsModule' does not appear to be an NgModule class.(-996002) forms.d.ts(33, 89534): This likely means that the library (@angular/forms) which declares FormsModule is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy. i'm using angular 10.1.4 which is the same version the teacher is using
@shyamprasanth1042
@shyamprasanth1042 Год назад
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
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
Yes will let you know
@anantsoni6335
@anantsoni6335 Год назад
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?
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
I think at the end, you also need to return value. 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; } } } } // something like this. return isMatch; }
@anantsoni6335
@anantsoni6335 Год назад
@@LearnProgrammingYourself Thank you it worked for me. One more issue I am unable to hide the login button during login one the system. Will you please help me into that ? header.component.html : Login Logout user-auth.service.ts: public isLoggedIn() { return this.getRoles() && this.getToken(); } header.component.ts: public logout() { console.log("Clicked"); this.userAuthService.clear(); console.log("logout() method execution is completed") this.router.navigate(["/home"]); } Please help me into this any feedback will be appreciated.
@LearnProgrammingYourself
@LearnProgrammingYourself Год назад
I think you missed "Not ( !)" for first button ng if. Login Logout focus on first button ng if condition.
Далее
다리에 힘이 풀려버린 슈슈 (NG Ver.)
00:11
Просмотров 2,7 млн
Difference between cookies, session and tokens
11:53
Просмотров 600 тыс.
Brutally honest advice for new .NET Web Developers
7:19
An Illustrated Guide to OAuth and OpenID Connect
16:36
Просмотров 565 тыс.
programming projects that taught me how to code
9:49
Просмотров 273 тыс.
Angular 18 is EXACTLY what we needed
9:15
Просмотров 65 тыс.
Why Signals Are Better Than React Hooks
16:30
Просмотров 462 тыс.
What Is JWT and Why Should You Use JWT
14:53
Просмотров 1,1 млн