mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 00:34:44 +02:00

* update composer.lock * run pint * fix phpstan * update migrations (sqlite `dropForeign`) * fix migrations * Reset these back for now * Alphabetize the rules * run `php artisan filament:upgrade` --------- Co-authored-by: Lance Pioch <git@lance.sh>
44 lines
1008 B
PHP
44 lines
1008 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Base;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Laravel\Socialite\Facades\Socialite;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Services\Users\UserUpdateService;
|
|
use Illuminate\Http\Response;
|
|
|
|
class OAuthController extends Controller
|
|
{
|
|
/**
|
|
* OAuthController constructor.
|
|
*/
|
|
public function __construct(
|
|
private UserUpdateService $updateService
|
|
) {}
|
|
|
|
/**
|
|
* Link a new OAuth
|
|
*/
|
|
protected function link(Request $request): RedirectResponse
|
|
{
|
|
$driver = $request->get('driver');
|
|
|
|
return Socialite::with($driver)->redirect();
|
|
}
|
|
|
|
/**
|
|
* Remove a OAuth link
|
|
*/
|
|
protected function unlink(Request $request): Response
|
|
{
|
|
$oauth = $request->user()->oauth;
|
|
unset($oauth[$request->get('driver')]);
|
|
|
|
$this->updateService->handle($request->user(), ['oauth' => $oauth]);
|
|
|
|
return new Response('', Response::HTTP_NO_CONTENT);
|
|
}
|
|
}
|