Master Laravel 11 API Authentication with Passport: Step-by-Step Guide

  Рет қаралды 3,782

Tutus Funny

Tutus Funny

Күн бұрын

Пікірлер
@sandhyamaurya4770
@sandhyamaurya4770 6 күн бұрын
Need to logout functionality
@eaad5101
@eaad5101 2 ай бұрын
How about function logout? i've try with $token = $request->user()->tokens(); $token->revoke(); but still, it doesn't work. Any solution?
@mdaohinuzzaman
@mdaohinuzzaman 6 күн бұрын
token,, not tokens
@Arya-si3ur
@Arya-si3ur 2 ай бұрын
when i paste the functions in the "AuthController.php" file it gives me error Undefined method 'attempt'.intelephense(P1013) Undefined method 'user'.intelephense(P1013) do you have any soulution?
@ryansumbele3552
@ryansumbele3552 8 күн бұрын
please did you solve this problem? i'm facing thesame issue, if you replace 'auth()' with 'Auth', it kind of solves that problem, but then i run into another error, 'undefined method createToken' in login functon
@Arya-si3ur
@Arya-si3ur 8 күн бұрын
@@ryansumbele3552 i downloaded (laravel idehelper) and it worked
@ryansumbele3552
@ryansumbele3552 8 күн бұрын
i found a solution , your register and login function in your authcontroller should look like this: public function register(Request $request) { $registerData = $request->validate([ 'name' => 'required|string|max:255', 'email' => 'required|string|email|max:255|unique:users', 'password' => 'required|string|min:8|confirmed' ]); $registerData['password'] = Hash::make($request->password); $user = User::create($registerData); $accessToken = $user->createToken('authToken')->accessToken; return response()->json([ 'user' => $user, 'access_token' => $accessToken, ],201); } public function login(Request $request) { $loginData = $request->validate([ 'email' => 'required|string|email', 'password' => 'required|string', ]); $user = User::where('email', $loginData['email'])->first(); if (!$user || !Hash::check($loginData['password'], $user->password)) { return response()->json(['message' => 'Invalid credentials'], 401); } $accessToken = $user->createToken('authToken')->accessToken; return response()->json([ 'user' => $user, 'access_token' => $accessToken, ],201); }
Laravel 11 REST APIs with Passport Auth Package - Hindi (Don't Miss it)
54:43
Laravel Sanctum + Register and Login
13:02
dbestech
Рет қаралды 38 М.
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 16 МЛН
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 18 МЛН
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
Laravel SPA Authentication - setup and common mistakes
16:55
Laravel REST API With Passport OAuth Authentication
23:25
Hardik Savani(ItSolutionStuff)
Рет қаралды 1,1 М.
Getting started with Laravel Passport and OAuth2
29:52
Andrew Schmelyun
Рет қаралды 77 М.
Laravel 11 JSON Web Token(JWT) Authentication
6:07
Binaryboxtuts
Рет қаралды 3,9 М.
Something is wrong with ISPs in India 🇮🇳
13:17
Mehul - Codedamn
Рет қаралды 85 М.
4 Tips for Building a Production-Ready FastAPI Backend
27:02
ArjanCodes
Рет қаралды 77 М.
The best Laravel project ideas for beginners
8:02
Josh Cirre
Рет қаралды 5 М.
Laravel 11 API in 13 minutes | Sanctum
13:49
WebDevWithArtisan
Рет қаралды 25 М.
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН