- Move billing routes from /billing to /settings/billing
- Add billing translations (en/pt-br)
- Update billing/Index.vue to use $t() for all strings
- Fix all controllers using route('dashboard') to use route('calendar') or route('accounts')
- Replace ->with('error', ...) pattern with session()->flash('flash.banner', ...)
- Add self-hosted mode support for hasActiveSubscription() and workspace methods
- Add flash translations for account connection errors
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
55 lines
1.5 KiB
PHP
55 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Auth;
|
|
|
|
use App\Enums\SocialAccount\Platform as SocialPlatform;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\View\View;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
class XController extends SocialController
|
|
{
|
|
protected string $driver = 'x';
|
|
|
|
protected SocialPlatform $platform = SocialPlatform::X;
|
|
|
|
protected array $scopes = [
|
|
'tweet.read',
|
|
'tweet.write',
|
|
'users.read',
|
|
'media.write',
|
|
'offline.access',
|
|
];
|
|
|
|
public function connect(Request $request): Response|RedirectResponse
|
|
{
|
|
$this->ensurePlatformEnabled();
|
|
|
|
$workspace = $request->user()->currentWorkspace;
|
|
|
|
if (! $workspace) {
|
|
return redirect()->route('workspaces.create');
|
|
}
|
|
|
|
$this->authorize('manageAccounts', $workspace);
|
|
|
|
$existingAccount = $workspace->socialAccounts()
|
|
->where('platform', $this->platform->value)
|
|
->first();
|
|
|
|
if ($existingAccount && ! $existingAccount->isDisconnected()) {
|
|
session()->flash('flash.banner', __('accounts.flash.already_connected'));
|
|
session()->flash('flash.bannerStyle', 'danger');
|
|
|
|
return back();
|
|
}
|
|
|
|
return $this->redirectToProvider($request, $this->driver, $this->scopes);
|
|
}
|
|
|
|
public function callback(Request $request): View
|
|
{
|
|
return $this->handleCallback($request, $this->platform, $this->driver);
|
|
}
|
|
}
|