L
L
lynnikvadim2016-05-02 17:04:00
API
lynnikvadim, 2016-05-02 17:04:00

Laravel Auth why is authorization not working?

25b0d6001f3e48ca9cb075cbf5be227d.png
I used socialiteproviders.github.io/providers/twitch packages
https://github.com/laravel/socialite
I used video as instructions: https://laracasts.com/series/whats-new-in-laravel-...
Rout :

Route::get('/twitch', 'Auth\[email protected]');

AuthController:
<?php

namespace App\Http\Controllers\Auth;

use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
use Laravel\Socialite\Facades\Socialite;
use App\AuthenticateUser;
use Illuminate\Http\Request;


class AuthController extends Controller
{
 

    public function twitch(AuthenticateUser $authenticateUser, Request $request )
    {
        
        return $authenticateUser->execute($request->has('code'));

    }
}

event service provider:
<?php

namespace App\Providers;

use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;

class EventServiceProvider extends ServiceProvider
{
    /**
     * The event listener mappings for the application.
     *
     * @var array
     */
    protected $listen = [
        'App\Events\SomeEvent' => [
            'App\Listeners\EventListener',
        ],
        \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        // add your listeners (aka providers) here
        'SocialiteProviders\Twitch\[email protected]',
    ],
    ];

    /**
     * Register any other events for your application.
     *
     * @param  \Illuminate\Contracts\Events\Dispatcher  $events
     * @return void
     */
    public function boot(DispatcherContract $events)
    {
        parent::boot($events);

        //
    }
}

AuthenticateUser.php :
<?php 
namespace App;
use Illuminate\Contracts\Auth\Authenticator;
use Laravel\Socialite\Contracts\Factory as Socialite;


class AuthenticateUser {

  private $users;
  private $socialite;
  private $auth;

  public function __construc(UserRepository $users, Socialite $socialite, Authenticator $auth)
  {
    $this->users = $users;
    $this->socialite = $socialite;
    $this->auth = $auth;
  }
  public function execute($hasCode)
  {
  
  if (! $hasCode) return $this->getAuthorizationFirst();
  $this->socialite->driver('twitch')->user();
  }
     
     private function getAuthorizationFirst()
     {
     	$user = $this->socialite->driver('twitch')->redirect();
     	dd($user);
     }
   
}

Where is the mistake ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
D', 2016-05-02
@lynnikvadim

public function __construc (UserRepository $users, Socialite $socialite, Authenticator $auth)
Is that a typo? Or is that how it is in the file?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question