Replace the per-platform native form POST + manual CSRF + JSON/Blade popup callback with a single Inertia mechanism: - popupCallback() renders the accounts/PopupCallback Inertia page (notifies the opener + closes the popup) for both the GET OAuth callbacks and the selection submits. Drops the auth.social-callback Blade view, the expectsJson JSON branch, and useHttp/useSocialConnect on the frontend. - Selection/credential pages (LinkedIn, Facebook, Instagram, Bluesky, Mastodon) use Inertia useForm: automatic CSRF + native validation errors. - Unify the three selection screens on one row + View/Choose layout; the LinkedIn company tag now uses a building icon. - Bluesky auth failures throw ValidationException (422 for XHR, redirect back with errors otherwise). Controller tests updated from assertViewIs/assertViewHas to assertInertia.
38 lines
1 KiB
PHP
38 lines
1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Controllers\Auth;
|
|
|
|
use App\Enums\SocialAccount\Platform as SocialPlatform;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Inertia\Response as InertiaResponse;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
class DiscordController extends SocialController
|
|
{
|
|
protected string $driver = 'discord';
|
|
|
|
protected SocialPlatform $platform = SocialPlatform::Discord;
|
|
|
|
public function connect(Request $request): Response|RedirectResponse
|
|
{
|
|
$this->ensurePlatformEnabled();
|
|
|
|
$workspace = $request->user()->currentWorkspace;
|
|
|
|
if (! $workspace) {
|
|
return redirect()->route('app.workspaces.create');
|
|
}
|
|
|
|
$this->authorize('manageAccounts', $workspace);
|
|
|
|
return $this->redirectToProvider($request, $this->driver, config('trypost.platforms.discord.scopes'));
|
|
}
|
|
|
|
public function callback(Request $request): InertiaResponse
|
|
{
|
|
return $this->handleCallback($request, $this->platform, $this->driver);
|
|
}
|
|
}
|