2018-10-04 19:10:43 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Auth;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
2018-11-02 11:54:46 +01:00
|
|
|
use App\Utils\Traits\UserSessionAttributes;
|
2018-10-04 19:10:43 +02:00
|
|
|
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
2018-10-18 07:04:36 +02:00
|
|
|
use Laravel\Socialite\Facades\Socialite;
|
2018-11-02 11:54:46 +01:00
|
|
|
use Illuminate\Http\Request;
|
2018-10-04 19:10:43 +02:00
|
|
|
|
|
|
|
class LoginController extends Controller
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Login Controller
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| This controller handles authenticating users for the application and
|
|
|
|
| redirecting them to your home screen. The controller uses a trait
|
|
|
|
| to conveniently provide its functionality to your applications.
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
use AuthenticatesUsers;
|
2018-11-02 11:54:46 +01:00
|
|
|
use UserSessionAttributes;
|
2018-10-04 19:10:43 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Where to redirect users after login.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2018-10-17 14:26:27 +02:00
|
|
|
protected $redirectTo = '/dashboard';
|
2018-10-04 19:10:43 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new controller instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
2018-10-15 07:00:48 +02:00
|
|
|
$this->middleware('guest:user')->except('logout');
|
2018-10-04 19:10:43 +02:00
|
|
|
}
|
2018-10-18 07:04:36 +02:00
|
|
|
|
2018-11-02 11:54:46 +01:00
|
|
|
public function authenticated(Request $request, $user)
|
|
|
|
{
|
|
|
|
$this->setCurrentCompanyId($user->companies()->first()->account->default_company_id);
|
|
|
|
}
|
|
|
|
|
2018-10-18 07:04:36 +02:00
|
|
|
public function redirectToProvider($provider)
|
|
|
|
{
|
|
|
|
return Socialite::driver($provider)->redirect();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function handleProviderCallback($provider)
|
|
|
|
{
|
|
|
|
$user = Socialite::driver('github')->user();
|
|
|
|
|
|
|
|
dd($user);
|
|
|
|
}
|
2018-10-04 19:10:43 +02:00
|
|
|
}
|