Laravel 11 - Auth Api - using sanctum ( Register, Login, Profile Data and Logout )

  Рет қаралды 5,658

Rubyvidhya Ammu

Rubyvidhya Ammu

Ай бұрын

#laravel11 #laravel_tutorial #laravel_api
Hi All,
Sorry! I used error code 401 for validation. The code is wrong.
Validation error code - 422
Unauthorized error code - 401
please change it while coding

Пікірлер: 18
@MakeeJkee
@MakeeJkee Күн бұрын
I even went to like it, it’s just my salvation, there is a bug in laravel 11 ->validate and this video saved me😍
@Foxine
@Foxine 16 күн бұрын
Thank you so much for this class! Thanks a lot! God bless you! Thank you!
@andreyp.5389
@andreyp.5389 Ай бұрын
Thanks a lot. Will fit for any level of developer :) I'm using laravel for 5-7 years but older versions mostly. I was surprised that 11th doesn't have scaffolded auth routes like it did before. From what I remember, previously you could just "php artisan make:auth" to have all needed auth routes
@suriyayash
@suriyayash Ай бұрын
nice one
@arsyadfinan9189
@arsyadfinan9189 2 күн бұрын
why when i try bearer is false not giving response unauthorized, but back to login route?
@tintrinh6266
@tintrinh6266 Ай бұрын
How appreciate I have! That's great, thank you so much.
@pacogarcia225
@pacogarcia225 19 күн бұрын
Do you have the code uploaded to a repository in Github? Thanks for your effort.
@MS_ELDERS
@MS_ELDERS 9 сағат бұрын
i have to implement in website how i supposed to do that any one know how to do it
@wildandvibe
@wildandvibe 3 күн бұрын
iam getting an error
@shubhamc4
@shubhamc4 Ай бұрын
On validation fail. You should return 422 validation http code instead of 401 which is for unauthorized access.
@rubyvidhyaammu4984
@rubyvidhyaammu4984 Ай бұрын
Thanks.... The error code detail was added in the description....
@DonLAtinop
@DonLAtinop Ай бұрын
Awesome video, thanks! btw , I am getting this in the profile link when the token is not right : Symfony\Component\Routing\Exception\RouteNotFoundException: Route [login] not defined. in file Any idea how to fix it?
@rubyvidhyaammu4984
@rubyvidhyaammu4984 Ай бұрын
The route is protected. Please add "Accept"=>"application/json" in Postman - Headers parameter. It will show: { "message": "Unauthenticated." } Laravel will check the configuration for "Accept", it will return the web page or html if no value is set at "Accept" by default.
@molefinance6826
@molefinance6826 Ай бұрын
@@rubyvidhyaammu4984 but since this is in the api routes, can't we automatically get this behaviour without the necessity to send the Accept type? This would prevent the error on this endpoint.
@jenneracostadiaz
@jenneracostadiaz Ай бұрын
Perffect 💖, one question please, in my intelephense return: Undefined method 'tokens'.intelephense(P1013) have you been able to resolve it?
@rubyvidhyaammu4984
@rubyvidhyaammu4984 Ай бұрын
You need to check your return type. You'll find the warnings go away if you wrote something like this. Please try this in function.... $user = Auth::user(); if ($user instanceof \App\Models\User) { // Hinting here for $user will be specific to the User object return $user->createToken("API TOKEN")->plainTextToken; } else { // Handle Error. Not logged in or guard did not return a User object. }
@user-oi5qj1hg1l
@user-oi5qj1hg1l 6 күн бұрын
@@rubyvidhyaammu4984 Hello, this worked for me. Is this a normal solution? public function logout(Request $request) { $request->user()->tokens()->delete(); return response()->json([ 'status' => true, 'message'=> 'User logged out', 'data' => [], ]); }
Laravel SPA Authentication - setup and common mistakes
16:55
Learnings from our multi-tenant Laravel application
9:58
Sabatino Talks Dev
Рет қаралды 11 М.
КАХА и Джин 2
00:36
К-Media
Рет қаралды 4 МЛН
Did you find it?! 🤔✨✍️ #funnyart
00:11
Artistomg
Рет қаралды 122 МЛН
[Vowel]물고기는 물에서 살아야 해🐟🤣Fish have to live in the water #funny
00:53
Laravel API with Sanctum and Breeze in 60 mins | Crash course
1:02:26
WebDevWithArtisan
Рет қаралды 11 М.
Building Secure Multi-Auth Systems in Laravel 11 with Laravel Breeze
29:36
Programming Fields
Рет қаралды 2,4 М.
Laravel Sanctum SPA Auth Overview
13:34
cdruc
Рет қаралды 6 М.
MongoDB Internal Architecture
43:25
Hussein Nasser
Рет қаралды 80 М.
Mastering Laravel 11 Roles and Permissions: A Comprehensive Guide
18:46
Code With ERaufi
Рет қаралды 1,9 М.
CORS in Laravel & Sanctum
10:38
cdruc
Рет қаралды 7 М.
15 crazy new JS framework features you don’t know yet
6:11
Fireship
Рет қаралды 404 М.
Laravel 11 tutorial 2024 - Build a REST API from scratch
46:54
Laravel 11: A new streamlined directory structure!
8:42
Laravel News
Рет қаралды 20 М.