invoiceninja/app/Http/Controllers/Auth/AuthController.php

60 lines
1.4 KiB
PHP
Raw Normal View History

2017-01-30 21:40:43 +02:00
<?php
namespace App\Http\Controllers\Auth;
2015-03-17 07:45:25 +10:00
2017-11-14 10:58:08 +02:00
use Illuminate\Http\Request;
2015-06-16 22:35:35 +03:00
use App\Ninja\Repositories\AccountRepository;
2015-10-11 17:41:09 +03:00
use App\Services\AuthService;
2017-11-14 10:58:08 +02:00
use App\Http\Controllers\Controller;
2015-03-17 07:45:25 +10:00
class AuthController extends Controller
{
/**
* @var AuthService
*/
2015-10-11 17:41:09 +03:00
protected $authService;
/**
* @var AccountRepository
*/
2015-06-16 22:35:35 +03:00
protected $accountRepo;
2015-03-29 15:37:42 +03:00
/**
* Create a new authentication controller instance.
*
* @param AccountRepository $repo
2017-01-30 21:40:43 +02:00
* @param AuthService $authService
*
* @internal param \Illuminate\Contracts\Auth\Guard $auth
* @internal param \Illuminate\Contracts\Auth\Registrar $registrar
*/
public function __construct(AccountRepository $repo, AuthService $authService)
{
2015-06-16 22:35:35 +03:00
$this->accountRepo = $repo;
2015-10-11 17:41:09 +03:00
$this->authService = $authService;
}
2015-03-17 07:45:25 +10:00
/**
* @param $provider
* @param Request $request
*
* @return \Illuminate\Http\RedirectResponse
*/
2017-11-14 10:58:08 +02:00
public function oauthLogin($provider, Request $request)
2015-10-11 17:41:09 +03:00
{
return $this->authService->execute($provider, $request->has('code'));
}
/**
* @return \Illuminate\Http\RedirectResponse
*/
2017-11-14 10:58:08 +02:00
public function oauthUnlink()
2015-10-11 17:41:09 +03:00
{
2017-11-14 10:58:08 +02:00
$this->accountRepo->unlinkUserFromOauth(auth()->user());
2015-10-11 17:41:09 +03:00
2017-11-14 10:58:08 +02:00
session()->flash('message', trans('texts.updated_settings'));
2017-01-30 21:40:43 +02:00
2015-10-20 11:23:38 +03:00
return redirect()->to('/settings/' . ACCOUNT_USER_DETAILS);
2015-10-11 17:41:09 +03:00
}
2015-03-17 07:45:25 +10:00
}