armingdev

armingdev

Member Since 3 Years Ago

Experience Points
7,370
Total
Experience

2,630 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
66
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 2
7,370 XP
Mar
26
1 week ago
Activity icon

Replied to Sanctum SPA Auth

bump any1?

Activity icon

Started a new Conversation Sanctum SPA Auth

Hello,

I have installed fresh copy of Laravel (without any fronted scaffolding or auth package) and installed Sanctum for SPA Auth. So Im using Laravel as API and separated RectJS app on frontend. I have setup Sanctum as documentation said, and have problems with accessing routes witch are protected with 'auth:sanctum' middleware.

As you can see on pictures:

  1. sending GET to set cookies - GET '/sanctum/csrf-cookie'

https://ibb.co/2qmLbgj

As you can se it set me two cookies.

  1. sending POST on my /api/login

https://ibb.co/HhzK3Fp

Login success ..

  1. sending GET to /api/users witch is protected by 'auth:sanctum middleware

https://ibb.co/F4TBXpg

As you can see It dosnt allow me to open it and redirecting me to the login route. In this case, error that said "Route [login] not defined." is not a problem since its just a pointing me to login route that I didn't write (since I'm using /api/route). Real problem is why it doesn't allow me to access route.

AutController login route:


    public function login(Request $request)
    {
        $credentials = $request->only('email', 'password');

        if (Auth::attempt($credentials)) {
            // Authentication passed...
            return response()->json(['message' => 'Login successful'], 200);
        }
    }

api routes:


Route::post('login', '[email protected]');

Route::middleware(['auth:sanctum'])->group(function () {

    Route::resources([
        'users' => 'UsersController',
    ]);
});

Also I have : cors.php

'supports_credentials' => true,

.env

SANCTUM_STATEFUL_DOMAINS=localhost,127.0.0.1
SESSION_DOMAIN=localhost

Did I miss something? Or maybe I can't test this trough POSTMAN?

Mar
25
1 week ago
Activity icon

Started a new Conversation Sanctum Roles & Permissions

Hi,

I have integrated Sanctum API Authorization for my app (Laravel API + React - as two separated projects) and I have made basic authentication. Now I need to work with roles and permissions. I saw Sanctum have abilities that I can attach to tokens. What is the best way to check abilities before it hit some action? Is there a better way then how its explained in documentation to check in contollers:


if ($user->tokenCan('server:update')) {
    //
}

I was looking for solution that Passport has, check on routes:


Route::get('/orders', function () {
    // Access token has both "check-status" and "place-orders" scopes...
})->middleware(['auth:api', 'scopes:check-status,place-orders']);

Mar
20
2 weeks ago
Activity icon

Replied to AirLock Route Protecting Issue

I have fixed errors from main post, actual problem is now that I wrote in my last replay.

"When I try to open any route protected with "auth:airlock'' I'm getting this error". So Im not talking about login because that route is out of middleware, that route is working.

Activity icon

Replied to AirLock Route Protecting Issue

Any1 had similar issues? Thx

Mar
19
2 weeks ago
Activity icon

Replied to AirLock Route Protecting Issue

As I said in my replay "When I try to open any route protected with "auth:airlock'' I'm getting this error". So Im not talking about login because that route is out of middleware, that route is working.

Activity icon

Replied to AirLock Route Protecting Issue

As you can see in my main post, I have 'resources' routs registered, so there should be GET, POST, PATCH, DELETE on users .. So routes are correct, they work when I remove auth:airlock middleware ..

Activity icon

Replied to AirLock Route Protecting Issue

Ok I have fixed this by adding:


Route::post('login', '[email protected]')->name('login');

Now I dont have that error anymore, but now Im running in another problem. When I try to open any route protected with "auth:airlock'' I'm getting this error:


Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException: The GET method is not supported for this route. Supported methods: POST. in file /home/vagrant/code/quarantine-bh/quarantine-bh-api/vendor/laravel/framework/src/Illuminate/Routing/AbstractRouteCollection.php on line 117

#0 /home/vagrant/code/quarantine-bh/quarantine-bh-api/vendor/laravel/framework/src/Illuminate/Routing/

Activity icon

Started a new Conversation AirLock Route Protecting Issue

Hello,

I have started new project using Laravel 7 (v7.2.0), and Im going to use AirLock to for my API Auth. I have installed it following official documentation but having problems with routes protecting.

Example of api.php route:


Route::middleware('auth:airlock')->group(function () {
    Route::resources([
        'users' => 'UsersController',
    ]);
});

When I try to access user routes I recive this error:


Symfony\Component\Routing\Exception\RouteNotFoundException: Route [login] not defined. in file /home/vagrant/code/quarantine-bh/quarantine-bh-api/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php on line 420

#0 /home/vagrant/code/quarantine-bh/quarantine-bh-api/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(766): Illuminate\Routing\UrlGenerator->route()
#1 /home/vagrant/code/quarantine-bh/quarantine-bh-api/app/Http/Middleware/Authenticate.php(18): route()
#2 /home/vagrant/code/quarantine-bh/quarantine-bh-api/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(83): App\Http\Middleware\Authenticate->redirectTo()
#3 /home/vagrant/code/quarantine-bh/quarantine-bh-api/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(68): Illuminate\Auth\Middleware\Authenticate->unauthenticated()
#4 /home/vagrant/code/quarantine-bh/quarantine-bh-api/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(42): Illuminate\Auth\Middleware\Authenticate->authenticate()
#5 /home/vagrant/code/quarantine-bh/quarantine-bh-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Auth\Middleware\Authenticate->handle()

Same is happening even when I add route for login:


Route::post('login', '[email protected]');

Anyone had similar problems with AirLock?

Feb
21
1 month ago
Activity icon

Replied to Sharing Data With Multiple Views With Request Querys

@atef95

I was thinking about Cache or Sessions, but thing is, route is open for everyone no auth required, so if one user open first link, and wait 1 minute, if anyone else open first link again it will overwrite key ... and it will show a car that second user cached ...

Activity icon

Replied to Sharing Data With Multiple Views With Request Querys

@dunsti

Hmmm but how can I pass parameters from my view to post method? Maybe to create some form with hidden fields.. or ?

Activity icon

Started a new Conversation Sharing Data With Multiple Views With Request Querys

Hi guys,

I have some specific situation where I have method in Controller that take some parameters from request and do some database query and return data to view. Thing is the on that view, I have link to another view that should use same data like previous one. I have read about View:Share or ViewComposer but it dosnet looks like good solution for me since I have to take some request params to do queries ..

Here is example:

Routes:

Route::post(‘car/car-pre-info', 'Api\[email protected]);
Route::post(‘car/car-info', 'Api\[email protected]’);

Controllers:

    public function preInfo(Request $request)
    {
        $car = Car::with('tags')->where('name', $request->carName)->get()->random();


        return view(‘car-pre-info’, [‘car’ => $car]);
    }

    public function info(Request $request)
    {
        return view(‘car-info’);
    }

So ‘preInfo’ method will bi triggered first, rend a view car-pre-info that will show some data from $car variable that I passed to view, and clicking on link on that view will call second method ‘info’ and rend a new view ‘car-info’ that should use same variable $car as previous view but il show other infromations stored in that variable ..

As you can see since Im getting random value in first method, I cant do query again in second one because it will get me a different car.