Тёмный

Laravel API Token Authentication and Model Observers (Ep 23) - Build an Advanced Blog & CMS 

DevMarketer
Подписаться 68 тыс.
Просмотров 31 тыс.
50% 1

Хобби

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

 

7 окт 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 39   
@robaei_net7199
@robaei_net7199 3 года назад
You are the Best Teacher
@arnelignacio2157
@arnelignacio2157 6 лет назад
thank you so much for this. i was able to use the observer to update the comment count in the post table every time a new comment was added. i am really learning a lot from you... i hope you will continue doing this tutorial videos.. you are a gift to all of us.
@ridwanajibari4443
@ridwanajibari4443 7 лет назад
subscribed, i need to watch all of your series
@raymondmichael4987
@raymondmichael4987 7 лет назад
Oooohps!! First to comment,API This will be much fun
@santoshwankhede5926
@santoshwankhede5926 7 лет назад
Sir I am a great fan of your teaching laravel and always wait for your next o ne video......Very few peoples are like you......Could you make a video on Jwt authentication for api in laravel..
@easyvideott7505
@easyvideott7505 7 лет назад
This one was really great!
@johnjosephflorina4450
@johnjosephflorina4450 6 лет назад
Nice video i like all your video
@arianeburnscodetv235
@arianeburnscodetv235 6 лет назад
THANK YOU
@xanthos733
@xanthos733 7 лет назад
Hey Alex, could you do a video or write down in the description which packages you are using for Atom?
@bloggervista
@bloggervista 7 лет назад
Nice
@Sinrise
@Sinrise 5 лет назад
Using Laravel 5.7, this isn't working when creating a new user. The seeding part works but I get "no default value for api_token" error when saving a new user.
@Sinrise
@Sinrise 5 лет назад
Once again I forgot about php artisan config:cache. After running that, it works.
@artyom_mezin
@artyom_mezin 5 лет назад
@@Sinrise thx! your comment is a key to this problem )
@moneymakr639
@moneymakr639 6 лет назад
@DevMarketer - great video..unfortunatly all I get is unauthortized when I try to to to my API url.
@mohamedmamdouh6453
@mohamedmamdouh6453 6 лет назад
Hi what if i have multilevel authentications like [ Users - Admins - Sellers ] etc , How could i manage the tokens and do you have a way to do that with JWY or Passport ? Thanks in Advance :)
@AbhimanyuNaikareWebDeveloper
@AbhimanyuNaikareWebDeveloper 5 лет назад
Would passport be a better alternative to videos 23?
@robbradley1337
@robbradley1337 5 лет назад
Yes.
@joegoodman4358
@joegoodman4358 4 года назад
if the token doesn't save with the other data, maybe you forgot to specify that api_token is a fillable attribute in your User.php file
@odunladeoluwaseun7880
@odunladeoluwaseun7880 7 лет назад
Thanks for awesome job u are doing sir. Please i asked a question on your previous laravel series but it has not been answered. (series 33). I love to add anchor tag on my categories so that when people click it, it loads posts under each category. I planned to launch my app by 17th of this month and this is the only functionality that remains
@elyunterim
@elyunterim 7 лет назад
how to make a modal dialog with buefy to delete an item from a data listing in a table? Are we going to learn this on the blog?
@timothyanderson9583
@timothyanderson9583 5 лет назад
8:50 - If I were drinking milk, it would have squirted out my nose.
@djebirihamza1098
@djebirihamza1098 6 лет назад
thank's for your help but i have a problem when i try to access in a page protect by auth:api with my vuejs function ($http ) it return this error 401 (Unauthorized) i'd like to redirect it to login page if user is a guest thank's a lot
@jamesparsons8546
@jamesparsons8546 6 лет назад
Where you are using axios through Laravel, I thought you didnt need api tokens as the request is validated through the auth middleware and session. Is there a reason why this wouldnt be secure?
@samerhameed320
@samerhameed320 6 лет назад
Hi Sir, First of all, a great thank for you amazing video that did, it’s really useful. I have a question about a Rest API, I will tell you what I am planning to do I have main application build with Laravel, it’s the main have all the data, and also have clients I want to install small application in their local server also build by laravel, to work locally and no need for internet access. What I am planning to do, is to make the client application talk with main application and fetch all the updated data, and the client application sends some data to the main application. As I know OAuth2 is the best way to make secure channel between two applications, if you have some video you made, and it may help me, please kindly share it with me. Or you may help by some advice. (I already try to do it, but I got some problem and error and I am not sure if I am using the right way to do it)
@akas_rai
@akas_rai 6 лет назад
I wanted to authenticate api with api_token and I have multiple auth system with different role. The api should only be accessed by admin group and selected role admin. For that I have done as follows in ApiController public function __construct() { $this->middleware('auth:admin'); // for admin authentication $this->middleware('superadmins'); //only superadmins role can access api } API url are all fine but i get error with above two lines. It says {"error":"unauthenticated."} But if i remove those middleware it works fine without authentication Note: I haven't used laratrust, all middleware are created manually
@SimionChis
@SimionChis 6 лет назад
For me, random is something like dice. Sometimes you have luck and you hit 6,6,6. If this happened in observer, i think the creating of user will stop and a error will be thrown. Am I right?
@advaithaj303
@advaithaj303 7 лет назад
What is the difference between observers and events? We can fire an even when ever we are creating, deleteing, etc or created, deleted, etc by using the dispatchesEvents protected variable inside the model
@JacurtisTutorials
@JacurtisTutorials 7 лет назад
Observers are "lower level". They won't be queued (like normally events would be) and they have DIRECT ACCESS to the model you are working with. Events are good for triggering things to happen like sending an email or a notification, but they arent good for directly manipulating the model, which is what we needed here. While you can trigger events at the "creating" state, the model doesn't wait around for the event and all of its listeners to complete. It simply triggers the event and keeps moving. The observer on the other hand is designed to directly manipulate the model. So it jumps in and runs its process and actually holds up the save() function while it works. So by targeting the "creating" stage, we know that the observer is going to be able to finish its job before the model continues the save process. So each has its own purpose. If i wanted to send a welcome email whenever a new user is added to the database, then creating an event tied to the "created" event would be the smarter way to do it. You wouldn't want to use observers for that task because 1) you want that process to be queued and observers can't be queued, and 2) you don't want the model to continue waiting on the observer to finish sending the email. So emails and notifications are great for events because they don't need direct access to the model (only a copy of it) and they can happen asynchronous of the event's save procedure. Observers are better for directly manipulating the model like we do in this video because we do want to hold up the save procedure until we generate that new api_token and we want it run synchronous to the save procedure. I have a video on using events to send a welcome email whenever a user is "created", if you want to see how you would do that: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-YHW5YzmA9_E.html
@ridwanajibari4443
@ridwanajibari4443 7 лет назад
i love how you explain this. thanks.
@christostsangaris4785
@christostsangaris4785 5 лет назад
@@JacurtisTutorials Always on point! Lucky to have you around Alex!
@saidulalam2840
@saidulalam2840 6 лет назад
hi, i am using laravel 5.6. i got a problem with auth:api. show Status Code: 401 Unauthorized. please help me.thanks
@siliver01
@siliver01 6 лет назад
How did you create that auth page?
@voneatpen6060
@voneatpen6060 7 лет назад
Hi, I have php -m, there is openssl but still when seeding, it says Field 'api_token' doesn't have a defau lt value. what should I do?
@robertomunhoz3399
@robertomunhoz3399 6 лет назад
I have the same problem. But when i put $user->api_token = bin2hex(openssl_random_pseudo_bytes(30)); in store on controller, it´s work. I´m confused now!
@skell_jams
@skell_jams 7 лет назад
Oh is this still happening
@水萌-y4h
@水萌-y4h 7 лет назад
sso?
@howtotech3956
@howtotech3956 4 года назад
he looks like eion musk
@MuhammadAdnan-gx6rd
@MuhammadAdnan-gx6rd 4 года назад
Hello ?
@yabreoumar6041
@yabreoumar6041 7 лет назад
You are the Best Teacher
Далее
Securing a Laravel API in 20 minutes with JWTs
20:36
Просмотров 78 тыс.
Websockets in Laravel: Part 0 - What are Websockets?
14:28
Laravel 8 REST API With Sanctum Authentication
54:13
Просмотров 547 тыс.
Difference between cookies, session and tokens
11:53
Просмотров 637 тыс.
You don't need a frontend framework
15:45
Просмотров 128 тыс.
Can You Turn On a TV With a Lighter?
0:48
Просмотров 22 млн
У этой девочки 1000 IQ
0:57
Просмотров 2,3 млн