voilatech

voilatech

Member Since 1 Year Ago

Montreal

Experience Points
1,850
Total
Experience

3,150 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
13
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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 1
1,850 XP
Oct
16
4 days ago
Activity icon

Replied to Laravel 6 Custom Guard Issue

@tonyfrenzy @joveice Finally after few days of search, I managed to make it working! So the Laravel Facade Auth dose not expect you to use it for a custom api guard! The only way to get it around "HACK" is just add another guard similar to web instance with the same provider as the api one. something like

'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],
        'partner-web' => [
            'driver' => 'session',
            'provider' => 'partners',
        ],

        'api' => [
            'driver' => 'passport',
            'provider' => 'users',
            'hash' => false,
        ],
        'partner_api' => [
            'driver' => 'passport',
            'provider' => 'partners',
            'hash' => false,
        ],
    ],

And then in your Controller:


if(Auth::guard('partner-web')->attempt([
            'partner_email' => request('partner_email'), 'password' => request('password'), 'account_status' => 1])){
            $partner = Auth::guard('partner-web')->user();

            $success['token'] = $partner->createToken('MyApp')->accessToken;
            $success['partner'] = Partner::with('partnerAddresses')->find($partner->id);

            return response()->json(['success' => $success], 201);
        }
        else{
            return response()->json(['error'=>'Unauthorised'], 401);
        }

Oct
10
1 week ago
Activity icon

Replied to Laravel 6 Custom Guard Issue

@joveice Here they are:


//Account registration
Route::post('register','API\[email protected]');

//Account activation
Route::get('signup/activate/{token}', 'API\[email protected]');

//Login , Logout
Route::post('login-user', 'API\[email protected]');
Route::post('login-partner', [ 'as' => 'login-partner', 'uses' => 'API\[email protected]']);
Route::post('logout', 'API\[email protected]');


Activity icon

Replied to Laravel 6 Custom Guard Issue

@joveice I don't think it's that as I just tried from Advanced REST client app to see the diff between postman and this one and got 302. I think somewhere laravel mixes with URI

    <!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="refresh" content="0;url=http://test.local/api/login-partner" />

        <title>Redirecting to http://test.local/api/login-partner</title>
    </head>
    <body>
        Redirecting to <a href="http://test.local/api/login-partner">http://test.local/api/login-partner</a>.
    </body>
</html>
Activity icon

Replied to Laravel 6 Custom Guard Issue

Thx @joveice! It's a POST request sir.And yes the first one got fixed , but that throws above error.

Activity icon

Replied to Laravel 6 Custom Guard Issue

Thx @tonyfrenzy ! I sorted the code out, but now it's throwing an error on the route

Symfony\Component\Routing\Exception\RouteNotFoundException: Route [login-partner] not defined. in file /usr/local/var/www/projects/mobilesante/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php on line 389

I put a name to my route and got below error:

my route:

Route::post('login-partner', [ 'as' => 'login-partner', 'uses' => 'API\[email protected]']);


Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException: The GET method is not supported for this route. Supported methods: POST. in file /usr/local/var/www/projects/mobilesante/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php on line 256

any thought?

Oct
09
1 week ago
Activity icon

Started a new Conversation Laravel 6 Custom Guard Issue

Hi Guys, I came across an issue with laravel 6 Auth where I added a new custom guard and when trying to authenticate a user, the Auth would check it with the default guard which is the api and it points to users table. Not to mention the default api guard, it works just fine! Even I tried to add the protected guard method in my Controller,

    protected function guard()
    {
        return \Illuminate\Support\Facades\Auth::guard('partner_api');
    }

but got no luck!

my Controller:

 public function __construct()
    {
            $this->middleware('auth:partner_api');
    }

    public function loginPartner(){
        if(Auth::attempt([
                'partner_email' => request('partner_email'), 'password' => request('password')]) && isset
            (Auth::user()
                    ->email_verified_at)){
            $partner = Auth::user();

            $success['token'] = $partner->createToken('MyApp')->accessToken;
            $success['partner'] = Partner::with('partnerAddresses')->find($partner->id);

            return response()->json(['success' => $success], 201);
        }
        else{
            return response()->json(['error'=>'Unauthorised'], 401);
        }
    }

My Auth.php

'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],

        'api' => [
            'driver' => 'passport',
            'provider' => 'users',
            'hash' => false,
        ],
        'partner_api' => [
            'driver' => 'passport',
            'provider' => 'partners',
            'hash' => false,
        ],
    ],
    'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => App\User::class,
        ],
        'partners' => [
            'driver' => 'eloquent',
            'model' => App\Partner::class,
        ],

        // 'users' => [
        //     'driver' => 'database',
        //     'table' => 'users',
        // ],
    ],

my Model:

    protected  $guard = 'partner_api';

Any thought?