diff --git a/app/Features/ManageBankAccounts.php b/app/Features/ManageBankAccounts.php deleted file mode 100644 index a3071e74..00000000 --- a/app/Features/ManageBankAccounts.php +++ /dev/null @@ -1,23 +0,0 @@ -isAdmin() ?? false; - } -} diff --git a/app/Http/Controllers/OpenBanking/ConnectionAccountController.php b/app/Http/Controllers/OpenBanking/ConnectionAccountController.php index 585ae013..5ce47252 100644 --- a/app/Http/Controllers/OpenBanking/ConnectionAccountController.php +++ b/app/Http/Controllers/OpenBanking/ConnectionAccountController.php @@ -3,7 +3,6 @@ namespace App\Http\Controllers\OpenBanking; use App\Contracts\BankingProviderInterface; -use App\Features\ManageBankAccounts; use App\Http\Controllers\Controller; use App\Http\Requests\OpenBanking\MapConnectionAccountRequest; use App\Jobs\SyncBankingConnectionJob; @@ -16,7 +15,6 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Log; use Inertia\Inertia; use Inertia\Response; -use Laravel\Pennant\Feature; class ConnectionAccountController extends Controller { @@ -24,7 +22,6 @@ class ConnectionAccountController extends Controller public function index(Request $request, BankingConnection $connection): Response { - $this->ensureFeatureEnabled(); $this->authorizeConnection($connection); $user = $request->user(); @@ -44,8 +41,6 @@ class ConnectionAccountController extends Controller public function map(MapConnectionAccountRequest $request, BankingConnection $connection, AccountUserCurrencyService $accountUserCurrencyService): RedirectResponse { - $this->ensureFeatureEnabled(); - $validated = $request->validated(); $uid = $validated['bank_account_uid']; @@ -109,7 +104,6 @@ class ConnectionAccountController extends Controller public function unlink(BankingConnection $connection, Account $account): RedirectResponse { - $this->ensureFeatureEnabled(); $this->authorizeConnection($connection); if ($account->banking_connection_id !== $connection->id) { @@ -124,11 +118,6 @@ class ConnectionAccountController extends Controller return back()->with('success', __('Account is no longer syncing. It is now a manual account.')); } - private function ensureFeatureEnabled(): void - { - abort_unless(Feature::for(auth()->user())->active(ManageBankAccounts::class), 403); - } - private function authorizeConnection(BankingConnection $connection): void { if ($connection->user_id !== auth()->id()) { diff --git a/app/Http/Middleware/HandleInertiaRequests.php b/app/Http/Middleware/HandleInertiaRequests.php index 4d3b4c6c..47a66ee0 100644 --- a/app/Http/Middleware/HandleInertiaRequests.php +++ b/app/Http/Middleware/HandleInertiaRequests.php @@ -5,7 +5,6 @@ namespace App\Http\Middleware; use App\Enums\BankingConnectionStatus; use App\Enums\BankingProvider; use App\Features\CalculateBalancesOnImport; -use App\Features\ManageBankAccounts; use App\Features\TransactionAnalysis; use App\Models\BankingConnection; use App\Services\CurrencyOptions; @@ -180,21 +179,18 @@ class HandleInertiaRequests extends Middleware 'cashflow' => true, 'calculateBalancesOnImport' => false, 'transactionAnalysis' => false, - 'manageBankAccounts' => false, ]; } $features = Feature::for($user)->values([ CalculateBalancesOnImport::class, TransactionAnalysis::class, - ManageBankAccounts::class, ]); return [ 'cashflow' => true, 'calculateBalancesOnImport' => $features[CalculateBalancesOnImport::class] !== false, 'transactionAnalysis' => $features[TransactionAnalysis::class] !== false, - 'manageBankAccounts' => $features[ManageBankAccounts::class] !== false, ]; } diff --git a/resources/js/pages/settings/connections.test.tsx b/resources/js/pages/settings/connections.test.tsx index df3e278e..1c3dbc09 100644 --- a/resources/js/pages/settings/connections.test.tsx +++ b/resources/js/pages/settings/connections.test.tsx @@ -29,7 +29,6 @@ vi.mock('@inertiajs/react', () => ({ cashflow: true, calculateBalancesOnImport: false, transactionAnalysis: false, - manageBankAccounts: true, }, }, }), diff --git a/resources/js/pages/settings/connections.tsx b/resources/js/pages/settings/connections.tsx index 30599e9a..c34828c8 100644 --- a/resources/js/pages/settings/connections.tsx +++ b/resources/js/pages/settings/connections.tsx @@ -44,8 +44,7 @@ interface Props { } export default function ConnectionsPage({ connections }: Props) { - const { auth, flash, subscriptionsEnabled, features } = - usePage().props; + const { auth, flash, subscriptionsEnabled } = usePage().props; const isDemoAccount = auth?.isDemoAccount ?? false; const isFreePlan = subscriptionsEnabled && !auth?.hasProPlan; const [connectDialogOpen, setConnectDialogOpen] = useState(false); @@ -287,23 +286,22 @@ export default function ConnectionsPage({ connections }: Props) { {__('Map Accounts')} )} - {features.manageBankAccounts && - canManageAccounts( - connection, - ) && ( - - router.visit( - `/open-banking/connections/${connection.id}/accounts`, - ) - } - > - - {__( - 'Manage Accounts', - )} - - )} + {canManageAccounts( + connection, + ) && ( + + router.visit( + `/open-banking/connections/${connection.id}/accounts`, + ) + } + > + + {__( + 'Manage Accounts', + )} + + )} {hasAuthError( connection, ) && ( diff --git a/resources/js/types/index.d.ts b/resources/js/types/index.d.ts index 856fb78a..87c4fd41 100644 --- a/resources/js/types/index.d.ts +++ b/resources/js/types/index.d.ts @@ -43,7 +43,6 @@ export interface Features { cashflow: boolean; calculateBalancesOnImport: boolean; transactionAnalysis: boolean; - manageBankAccounts: boolean; } export interface ExpiredBankingConnectionNotification { diff --git a/tests/Feature/InertiaSharedDataTest.php b/tests/Feature/InertiaSharedDataTest.php index edffa438..120aab4f 100644 --- a/tests/Feature/InertiaSharedDataTest.php +++ b/tests/Feature/InertiaSharedDataTest.php @@ -44,7 +44,6 @@ test('shared feature flags do not include coinbase flag', function () { 'cashflow' => true, 'calculateBalancesOnImport' => false, 'transactionAnalysis' => false, - 'manageBankAccounts' => false, ]); }); diff --git a/tests/Feature/OpenBanking/ConnectionAccountTest.php b/tests/Feature/OpenBanking/ConnectionAccountTest.php index 3b53bb37..d32698d2 100644 --- a/tests/Feature/OpenBanking/ConnectionAccountTest.php +++ b/tests/Feature/OpenBanking/ConnectionAccountTest.php @@ -17,21 +17,13 @@ beforeEach(function () { ]); }); -/** - * The manage-accounts surface is gated behind the ManageBankAccounts feature, - * which is only active for the admin user. Mark the created user as the admin so - * the gate lets the request through. - */ -function adminUser(): User +function onboardedUser(): User { - $user = User::factory()->onboarded()->create(); - config(['mail.admin_email' => $user->email]); - - return $user; + return User::factory()->onboarded()->create(); } test('index renders the manage page with synced and available accounts', function () { - $user = adminUser(); + $user = onboardedUser(); $connection = BankingConnection::factory()->create(['user_id' => $user->id]); Account::factory()->for($user)->create([ @@ -56,7 +48,7 @@ test('index renders the manage page with synced and available accounts', functio }); test('refresh discovers bank accounts that are not yet synced', function () { - $user = adminUser(); + $user = onboardedUser(); $connection = BankingConnection::factory()->create(['user_id' => $user->id]); Account::factory()->for($user)->create([ @@ -94,7 +86,7 @@ test('refresh discovers bank accounts that are not yet synced', function () { test('map create adds a new synced account and dispatches a sync', function () { Queue::fake(); - $user = adminUser(); + $user = onboardedUser(); $connection = BankingConnection::factory()->create([ 'user_id' => $user->id, 'aspsp_name' => 'Test Bank', @@ -125,7 +117,7 @@ test('map create adds a new synced account and dispatches a sync', function () { test('map link moves syncing to another account and unlinks the previous one', function () { Queue::fake(); - $user = adminUser(); + $user = onboardedUser(); $connection = BankingConnection::factory()->create(['user_id' => $user->id]); $source = Account::factory()->for($user)->create([ @@ -160,7 +152,7 @@ test('map link moves syncing to another account and unlinks the previous one', f }); test('unlink stops syncing but keeps the account and its transactions', function () { - $user = adminUser(); + $user = onboardedUser(); $connection = BankingConnection::factory()->create(['user_id' => $user->id]); $account = Account::factory()->for($user)->create([ @@ -182,7 +174,7 @@ test('unlink stops syncing but keeps the account and its transactions', function }); test('index is forbidden for another user\'s connection', function () { - $user = adminUser(); + $user = onboardedUser(); $connection = BankingConnection::factory()->create([ 'user_id' => User::factory()->onboarded()->create()->id, ]); @@ -193,7 +185,7 @@ test('index is forbidden for another user\'s connection', function () { }); test('unlink rejects an account that does not belong to the connection', function () { - $user = adminUser(); + $user = onboardedUser(); $connection = BankingConnection::factory()->create(['user_id' => $user->id]); $account = Account::factory()->for($user)->create([ 'banking_connection_id' => null, @@ -204,18 +196,8 @@ test('unlink rejects an account that does not belong to the connection', functio ->assertNotFound(); }); -test('manage accounts is forbidden when the feature is disabled', function () { - $user = User::factory()->onboarded()->create(); - config(['mail.admin_email' => 'someone-else@example.com']); - $connection = BankingConnection::factory()->create(['user_id' => $user->id]); - - $this->actingAs($user) - ->get(route('open-banking.connection-accounts.index', $connection)) - ->assertForbidden(); -}); - test('map link rejects a non-transactional target account', function () { - $user = adminUser(); + $user = onboardedUser(); $connection = BankingConnection::factory()->create(['user_id' => $user->id]); $loan = Account::factory()->for($user)->create([ 'banking_connection_id' => null,