How to create a Login function using JWT and Cookies in Laravel 9 - Learn Laravel API Tutorial - Ep3
Вставка
- Опубліковано 21 жов 2024
- In this series we will focus on Laravel API development and in this episode we will cover:
API Login feature using JWT tokens and Cookies
Please see the Github repository for the code within this episode github.com/Pix...
Episode 4 is here • How to create Observer... .
We will cover sending a welcome email using 3 different ways by using the Controller, the Model Observer, and the Events and Listeners.
Click here to subscribe
/ @codingwithpixelfix
Laravel Naming Conventions
• Laravel Naming Convent...
I offer free code reviews as a way to give back and share my knowledge with the community. So, please feel free to reach out if interested. My contact details are available on the channel's about page or checkout the links below: / @codingwithpixelfix
Reddit
/ laravelcodereviews
Medium
/ codingwithpixelfix
Facebook
/ codingwithpixelfix
Twitter
/ pixelfixnetau
LinkedIn
/ codingwithpixelfix
Github
github.com/pix...
#laravel #howto #webdevelopment
The best as always!
Thanks mate
Hello, does it change if we have sanctum?
Hey, yes the implementation I showed in the video is already working with sanctum. So, no need to change anything.
best tutorial but it was best if you told as how to add Firebase dependencies for use of JWT
as below
for me I found this dependency and worked -> composer require firebase/php-jwt
Thank you
Thank you for the tip. I will keep that in mind for future reference.
I followed your coding, but when I try to login it gives me the error "Cannot use object of type stdClass as array". I figured it out, that it works, when I change the line to $jwtDecoded = (array)JWT::decode($jwtCookie, new Key(config('app.key'), 'HS256'));
But that doesn't seem right to me. Do you have a clue, what gone wrong?
Thanks for the note. It seems like according to the documentation that the decode function now returns an object instead of an associative array. So what you have done is perfectly correct. You can reference the documentation here github.com/firebase/php-jwt
@@stan9345 Your encrypted token should be the first element in the array, so you can probably try this: Crypt::decrypt($jwtDecoded[0]) - Let me know if it works.