If you'd like to see the full source code behind this video, you can check it out on my GitHub here: github.com/aschmelyun/video-auth-vue-laravel-sanctum
@moranilt4 жыл бұрын
$request->user()->secrets isn't working. 500 ERROR is always response. But Secrets::all() is working good. Any ideas how to fix?
@claudio-emmanuel3 жыл бұрын
Hi Andrew, what are your IDE's theme and font settings? and which IDE are you using?
@bruttavoglia3 жыл бұрын
Hi Andrew! I want to implement even registration from Vue, if I'm not wrong it's just move the user creation process from UserFactory to Register.vue component right?
@mihoteo3 жыл бұрын
@@moranilt I would like to know too.
@danishirfanshah57702 жыл бұрын
@@moranilt hey, did you get the answer. i also have same problem
@ademtepe28553 жыл бұрын
One of the fullest 23 mins of my life, thank you for making such a clear and concise video. (Well, it's 23 mins but actually I watched, applied and worked on this video and subject all day.)
@aschmelyun3 жыл бұрын
Thank you so much! That means a lot to me, I'm glad you enjoyed the video!
@DarylLegion4 жыл бұрын
Your tutorials are well explained. Please make a series of this Laravel Vue + Sanctum
@ademtepe28553 жыл бұрын
I would appreciate that too. A simple but full app example would be great!
@dawidwinkler38543 жыл бұрын
I don't get it. As already someone mentioned, the XSRF-Token already exists without /sanctum/csrf-cookie, wo why do we call that? And it says, that after a successful login I can call any other api routes, yes, of course, couse there is no auth:sanctum middleware in your secrets api call, so i can call that through postman too.
@shamscorner4 жыл бұрын
Man!!! The video quality is A+
@icekalang35982 жыл бұрын
what happens when you accidentally refresh the page?
@Tyche.Crypto4 жыл бұрын
Would you please make a video about protecting the routes with the sanctum, and how to refresh or expire the token.
@aschmelyun4 жыл бұрын
Sure! I will add it to my list.
@tysonadeyemi37263 жыл бұрын
I was wondering if Sanctum can be used for a Multi guard set up such as Admin, Customer and Vendor type of setup
@kennyteoh44093 жыл бұрын
Hi, isn't your "api/secrets" api path been expose to frontend. Where anyone can use postman to call the "api/secrets" without authenticate?
@FilipBekic014 жыл бұрын
Why do we do GET /sanctum/csrf-cookie if we already have XSRF-TOKEN in our cookies?
@sevolaiser4 жыл бұрын
If I try to retrieve the user secrets I get the error that there is no User on the request. I dont know why he is telling me im not logged in after entering the right credentials. What could be the problem?
@AllanVigiano4 жыл бұрын
same problem here... I have a git clone and then composer update, npm install and php artisan migrate (plus factories). So strange!
@marcuu53 жыл бұрын
Is it possible to use the Laravel ui auth forms and laravel sanctum or do you have to write your own login form?
@MrEdSaints2 жыл бұрын
It would be amazing if you could make an updated version of this ..
@JJ-ot3ps2 жыл бұрын
is this one the same as laravel breeze that comes with vue? and maybe add vite ?
@someone-jq3lc4 жыл бұрын
what font family you are using in your editor?
@digitaluniverse98263 жыл бұрын
Andrew how do we logout with this cookie stuff?
@sukatuabdullahithedevissa44542 жыл бұрын
Thank you very much for a beautiful short and detailed tutorial.
@Cybersix66664 жыл бұрын
Great video... would you make a video on how to deploy this into a live server ? I dont seem to be able to find one ... thanks
@claudio-emmanuel3 жыл бұрын
Hi Andrew, what are your IDE's theme and font settings? and which IDE are you using?
@Ahmed-1572 жыл бұрын
This was a perfectly made tutorial! Do you plan to make more Vue and Laravel tutorials?
@КириллБелоусов-ы5е3 жыл бұрын
in which folder is the admin panel created? in client project or inside laravel project?
@anbuselvanrocky4 жыл бұрын
What are the code extensions and configurations you are using?
@dgloria4 жыл бұрын
My problem with this that my api is not protected from third party if I call myApp/public/api/secrets page. So that would be a security issue. How would you do that? Eg. in postman you aren't able to access the api only if I provide you an access bearer token. One little addition, when you make a video, please keep bottom 3% free from content, I can't see your terminal commands of the youtube progress bar correctly when pausing the video. Thank you.
@redonechkernit55103 жыл бұрын
Thank you about this video. How i can check if user authenticated ?
@softwareEngineerKunwar3 жыл бұрын
Great tutorial. The description is clear and to the point. Would you mind to make full new video for laravel 8 vue3 + sanctum rest api full stack? Thanks in advance.
@henriqueferr86234 жыл бұрын
I'm having a problem at 20:20. When i go into 'localhost:8000/api/secrets' it says that i'm "trying to get property 'secrets' of non-object". When I try only to return $request->user() it shows nothing. I'm using Laravel 8
@beehive2194 жыл бұрын
Make sure you added your domain (for me, using Valet, It's 'spa.test') to the 'stateful' option in config/sanctum.php :)
@drsolace4 жыл бұрын
@@beehive219 Thanks Lars!
@mihoteo3 жыл бұрын
@@beehive219 Doesnt work for me. It still shows non-object instead of data :/
@Simone-ft2cg4 жыл бұрын
Hi, Thanks for this video! I need to make a PUT api Route to modify the product in the cart. Can I just write the route in api.php or I need Laravel Sanctum?
@thomaspotterdotexe3 жыл бұрын
Did you know what vscode extension to install to make showing the identifier, like that 'table' and 'column' in migration file? thanks!
@aschmelyun3 жыл бұрын
Hey Thomas! I believe for this video, I used the PHP Intelephense plugin: marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client
@thomaspotterdotexe3 жыл бұрын
@@aschmelyun oh, I use that too but it doesn't showing like that ("table", "column", etc) idk why :'(
@jerickcarlosmangalus68563 жыл бұрын
i'm having problems with laravel santum its very slow in response when i use sails in docker ? any idea how to fix this ?
@lloparyllopary3 жыл бұрын
which code editor do you use? And if it is vscode which extensions do you have?
@aschmelyun3 жыл бұрын
I'm using PHPStorm with the Material UI Theme plugin set to the Atom One Dark color scheme!
@lloparyllopary3 жыл бұрын
@@aschmelyun thanks!!
@Vtivo4 жыл бұрын
Thanks for the course, hoping to understand Sanctum more... @5:25 In Tinker when I run: App\User::with('secrets')->get(); I get the following error: PHP Error: Call to a member function addEagerConstraints() on null in /Users/[username]/Sites/sanctum/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php on line 578 Can you help?
@Vtivo4 жыл бұрын
My follow along version uses Laravel Framework 7.25.0. App\Secret::with('user')->get() works. I downloaded & setup your repo (Laravel Framework 7.9.2) both tinker queries worked fine, has anything changed on the newer version of Laravel?
@aschmelyun4 жыл бұрын
Hey Dino! Check your User.php model, where you're defining the public function secrets() method and make sure that there's a return statement. You should have something like: public function secrets() { return $this->hasMany('App\Secret'); }
@kosticnemanja19144 жыл бұрын
Work through the Controller, not through the Tinker... App\Secret::with('user')->get(); WORKING App\User::with('secrets')->get(); NOT WORKING ?? HELP Illuminate/Database/Eloquent/RealationNotFoundException with message 'Call to undefined realationship [secrets] on model [App/User]
@alexandriv21743 жыл бұрын
what is it dcr?
@raufhashimov2414 жыл бұрын
Thanks man youre channel best for anyone whos learning laravel.If you also will show auth laravel sanctum with react that's will be great.And try to show every example using react because developers usually use react.
@nirajgautam4033 жыл бұрын
lets say im at dashboard , and im making axios call to get user which is protected with auth:sanctum middleware , do i have to send the token manually through my axios call or it will work just fine
@aschmelyun3 жыл бұрын
As long as it's coming from the same domain name, you shouldn't have to include the token at all. You may need to add withCredentials: true to your axios initialization though.
@stanislavkacmarik62104 жыл бұрын
Why is this much better option then tymon/jwt-auth? Is it more secure? Or does sanctum solve some problems that are in tymon/jwt-auth? Or is it just easier to setup?
@aschmelyun4 жыл бұрын
It works similarly behind the scenes for API tokens, but also does a lot of authentication setup automatically when combined with frontend JavaScript calls. It’s also an official Laravel repository, meaning that it will be updated consistently as the framework is!
@richardwheatley71944 жыл бұрын
I was building on valet and failed to pick up domain config, but otherwise a great tutorial in both content and delivery.
@SussanRai4 жыл бұрын
How can i get auth user in public api using scantum
@Venezuelangel3 жыл бұрын
I'm sorry for being lost, but what password are you using to log in to your dummy users (it's hashed in the DB, of course).
@SabinMehedin3 жыл бұрын
Hi! The password is password. In your factory file can see a comment near the hash: // password :)
@stefantatic48364 жыл бұрын
Hi, Andrew, awesome video. Regarding the last example, I assume it's easier and more robust to use the auth:sanctum (instead of the default auth:api) middleware on protected routes? This way it'll throw a 401 (unauthenicated) and for some routes 403 (unauthorized) error which is clearer than "general" 500 (internal server error). Of course, the biggest plus you get is that you can set this middleware on your controller's constructor/chain it in the routes file instead of performing the checks for each controller's method. Am I right to point this out? Another comment: is there something that can be done to handle redirection of your Vue frontend in the same way Laravel does it out of the box for back-end served apps? I'm specifically thinking (but you might add something as well) about RedirectIfAuthenticated middleware which prevents signed-in users from reaching e.g. Login/Register pages. How can this be tackled for your Vue front end app? Thanks again for this great tutorial, I subscribed and hope to see more cool videos from you. Keep up!
@stefantatic48364 жыл бұрын
Also, the thing I'm baffled for the last 3 days: how do you handle the (authenticated) User object? E.g: you want your navbar to have the user options on top or login/register if no one's signed in and of course have this updated on login/logout. Do you keep the object on the root instance and have all your other components (e.g. mentioned top navbar, but also sidebar which can show different options to admin/regular user/guest user) update on this change or... Let me know if you need me to explain it a bit more, I hope you get my question. I am somewhat experienced with Laravel, but I'm pretty new to Vue and I'm currently building my first SPA so it's a fun journey. 😃
@orlandoubilla70554 жыл бұрын
Hi! if your .env file have the var SANCTUM_STATEFUL_DOMAINS and using localhost over some port (like 8080) , add it too. SANCTUM_STATEFUL_DOMAINS=localhost:8080 Regards.-
@DavixeTheBoss4 жыл бұрын
@@stefantatic4836 For this kind of use cases, i think the best is to use Vuex
@maulik16444 жыл бұрын
Which IDE are you using??🤔 Is that php Strom??
@aschmelyun4 жыл бұрын
Yes! It's using the Material Theme UI with Firacode as the font.
@wojciech-koziol4 жыл бұрын
Hi, great tutorial but I've got problem with login in. When I do axios.post on route /login I've got error: errors: {email: ["These credentials do not match our records."]} message: "The given data was invalid." I've checked up several times and inputed data is correct.
@wojciech-koziol4 жыл бұрын
Okey, I solved the problem. I just created manually user.
@hanimajebry49704 жыл бұрын
13:30 , you could've used `form-group` class
@robbichandra62793 жыл бұрын
Can you do full tutorial please
@aschmelyun3 жыл бұрын
It's on my to-do list! Keep an eye out for future videos!
@ronnelsuan58464 жыл бұрын
Hi i have vue login page. and i just want to implement sanctum on may login. it should i need secret or not ?
@ronnelsuan58464 жыл бұрын
if it's okay my login is vue only then after i logged in its typical laravel blade templating?
@ronnelsuan58464 жыл бұрын
what's the use of personal token access in sanctum ?
@kushtra244 жыл бұрын
Does this work for laravel 8?
@nirmaldangi8774 жыл бұрын
I have problem in using laravel8
@michaelerwin87444 жыл бұрын
Since this relies on cookies for security, how does mobile app integration work using same API?
@aschmelyun4 жыл бұрын
If you check out the Laravel Sanctum documentation, there's a whole section about using bearer tokens as authentication. You can pass them through as an Authorization header to your API requests!
4 жыл бұрын
Hello there! I try this with Laravel 8, and I'm blocked by this error: "localhost:8000/login 404 (Not Found)" What could be the problem?
@moranilt4 жыл бұрын
Hi. Just try to read laravel.com/docs/8.x/sanctum There are some differences between v7 and v8 of Laravel. YOu don't need to install laravel/ui. Instead you should use laravel/jetstream
4 жыл бұрын
@@moranilt Yep, thank you very much, I realized by now that 8 is different in that field... so I started a new project installing Jetstream, now I'm configuring my Vue app to handle the login/logout requests, check if someone is authenticated, etc...
@guillercelestino8014 жыл бұрын
Can please add on how to refresh the token.
@aschmelyun4 жыл бұрын
Sure thing! I'll add this to my list of upcoming videos, keep an eye out!
@rosesolution24353 жыл бұрын
Can't see the commands
@FilipBekic014 жыл бұрын
I've thinking about Sanctum and.. if you use just a simple authorization system, why do you even need Sanctum? Can't you just authorize normaly vie axios request? Sanctum may be useful only issuing API tokens which you do not do in the video.
@aaronmeder4 жыл бұрын
Thanks, great overview!
@JohnnyBigodes4 жыл бұрын
Awesome as always.... Thank you
@ahmadabuaysheh4 жыл бұрын
Really clear and amazing video. Thank you!
@SergeySSD3 жыл бұрын
work with token match easy and better if need full cross domain
@neomn1102 жыл бұрын
13:55
@Lumaport4 жыл бұрын
Awesome video thank you
@Sub_Boi10 ай бұрын
Thank you
@igorthierry3 жыл бұрын
if you want to make requests for api routes from a web page SESSION_DRIVER=cookie SESSION_DOMAIN=localhost SANCTUM_STATEFUL_DOMAINS=localhost:8000
@eisa343s4 жыл бұрын
Thanks.
@akiaksandrpapilau9324 жыл бұрын
artisan make:controller SicretController - makes a new blank class with the name SicretController, it is so useful, i do not even know how i would live without this help, lmao, every day i get more and more disappointed about this framework, also you tutorial is not relevant alredy for the 8th version. f**k do these guys have anything permanent?
@franzkafka97343 жыл бұрын
Русскоговорящим ку У кого его метод не работает пишите: App\Models\User::factory()->create();
@mihaylov133 жыл бұрын
Тода Андрей
@joshuaabejero95922 жыл бұрын
OMG I almost run go back to ExpressJS! You saved me a lot of trouble. Now I can access the AUTH User using $request-user()->id.
@SquarCoX4 жыл бұрын
How do i check in each component if the user is authenticated??
@DavixeTheBoss4 жыл бұрын
The best option for this, in my opinion, is to save the user data in a global, eg: Vuex, check if the user is authenticated or not before accessing any route within the Vue Router and this way you could define which components could the user access or not.