invoiceninja/app/Http/Controllers/Auth/LoginController.php
David Bomba af9ae06289
Model encode primary keys (#2510)
* Client Address

* Vue components for address

* Fix for null objects being passed to Vue

* Copy Billing Address

* route key

* Social auth

* Pad out route bindings

* Deploy hashes across models

* social auth buttons
2018-11-20 15:36:56 +11:00

81 lines
2.0 KiB
PHP

<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Utils\Traits\UserSessionAttributes;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Laravel\Socialite\Facades\Socialite;
use Illuminate\Http\Request;
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;
use UserSessionAttributes;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/dashboard';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest:user')->except('logout');
}
/**
* Once the user is authenticated, we need to set
* the default company into a session variable
*
* @return void
*/
public function authenticated(Request $request, $user)
{
$this->setCurrentCompanyId($user->companies()->first()->account->default_company_id);
}
/**
* Redirect the user to the provider authentication page
*
* @return void
*/
public function redirectToProvider($provider)
{
return Socialite::driver($provider)->redirect();
}
/**
* Received the returning object from the provider
* which we will use to resolve the user
*
* @return redirect
*/
public function handleProviderCallback($provider)
{
$user = Socialite::driver($provider)->user();
/** If user exists, redirect to dashboard */
/** If user does not exist, create account sequence */
dd($user);
}
}