Skip to content

Commit 1b40adf

Browse files
committed
Remove license unsuspension
1 parent d50ce4d commit 1b40adf

File tree

7 files changed

+26
-59
lines changed

7 files changed

+26
-59
lines changed

app/Http/Controllers/CustomerLicenseController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ public function index(): View
2525
public function show(string $licenseKey): View
2626
{
2727
$user = Auth::user();
28-
$license = $user->licenses()->with('subLicenses')->where('key', $licenseKey)->firstOrFail();
28+
$license = $user->licenses()
29+
->with('subLicenses')
30+
->where('key', $licenseKey)
31+
->firstOrFail();
2932

3033
return view('customer.licenses.show', compact('license'));
3134
}

app/Http/Controllers/CustomerSubLicenseController.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use App\Actions\SubLicenses\DeleteSubLicense;
66
use App\Actions\SubLicenses\SuspendSubLicense;
7-
use App\Actions\SubLicenses\UnsuspendSubLicense;
87
use App\Http\Requests\CreateSubLicenseRequest;
98
use App\Jobs\CreateAnystackSubLicenseJob;
109
use App\Jobs\UpdateAnystackContactAssociationJob;
@@ -105,21 +104,6 @@ public function suspend(string $licenseKey, SubLicense $subLicense): RedirectRes
105104
->with('success', 'Sub-license suspended successfully!');
106105
}
107106

108-
public function unsuspend(string $licenseKey, SubLicense $subLicense): RedirectResponse
109-
{
110-
$user = Auth::user();
111-
$license = $user->licenses()->where('key', $licenseKey)->firstOrFail();
112-
113-
// Verify the sub-license belongs to this license
114-
if ($subLicense->parent_license_id !== $license->id) {
115-
abort(404);
116-
}
117-
118-
app(UnsuspendSubLicense::class)->handle($subLicense);
119-
120-
return redirect()->route('customer.licenses.show', $licenseKey)
121-
->with('success', 'Sub-license unsuspended successfully!');
122-
}
123107

124108
public function sendEmail(string $licenseKey, SubLicense $subLicense): RedirectResponse
125109
{

app/Models/License.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function getRemainingSubLicensesAttribute(): ?int
9191
return null; // Unlimited
9292
}
9393

94-
$used = $this->subLicenses()->count();
94+
$used = $this->subLicenses()->where('is_suspended', false)->count();
9595

9696
return max(0, $limit - $used);
9797
}
@@ -115,16 +115,12 @@ public function canCreateSubLicense(): bool
115115
return $remaining === null || $remaining > 0;
116116
}
117117

118+
118119
public function suspendAllSubLicenses(): int
119120
{
120121
return $this->subLicenses()->update(['is_suspended' => true]);
121122
}
122123

123-
public function unsuspendAllSubLicenses(): int
124-
{
125-
return $this->subLicenses()->update(['is_suspended' => false]);
126-
}
127-
128124
protected static function boot(): void
129125
{
130126
parent::boot();

app/Models/SubLicense.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,4 @@ public function suspend(): bool
105105
return $this->update(['is_suspended' => true]);
106106
}
107107

108-
public function unsuspend(): bool
109-
{
110-
return $this->update(['is_suspended' => false]);
111-
}
112108
}

resources/views/customer/licenses/index.blade.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@
1717
<a href="{{ route('pricing') }}" class="inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
1818
Buy more
1919
</a>
20-
<form method="POST" action="{{ route('customer.logout') }}">
21-
@csrf
22-
<button type="submit" class="inline-flex items-center px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
23-
Sign out
24-
</button>
25-
</form>
2620
</div>
2721
</div>
2822
</div>

resources/views/customer/licenses/show.blade.php

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@
3333
<a href="{{ route('customer.billing-portal') }}" class="inline-flex items-center px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
3434
Billing
3535
</a>
36-
<form method="POST" action="{{ route('customer.logout') }}">
37-
@csrf
38-
<button type="submit" class="inline-flex items-center px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
39-
Sign out
40-
</button>
41-
</form>
4236
</div>
4337
</div>
4438
</div>
@@ -181,7 +175,7 @@ class="ml-2 inline-flex items-center px-2.5 py-1.5 border border-gray-300 dark:b
181175
<h3 class="text-lg leading-6 font-medium text-gray-900 dark:text-white">
182176
Keys
183177
<span class="ml-2 text-sm text-gray-500 dark:text-gray-400">
184-
({{ $license->subLicenses->count() }}{{ $license->subLicenseLimit ? '/' . $license->subLicenseLimit : '' }})
178+
({{ $license->subLicenses->where('is_suspended', false)->count() }}{{ $license->subLicenseLimit ? '/' . $license->subLicenseLimit : '' }})
185179
</span>
186180
</h3>
187181
<p class="mt-1 max-w-2xl text-sm text-gray-500 dark:text-gray-400">
@@ -264,7 +258,7 @@ class="text-blue-600 hover:text-blue-500 text-sm"
264258
>
265259
Edit
266260
</button>
267-
<form method="POST" action="{{ route('customer.licenses.sub-licenses.suspend', [$license->key, $subLicense]) }}" class="inline">
261+
<form method="POST" action="{{ route('customer.licenses.sub-licenses.suspend', [$license->key, $subLicense]) }}" class="inline" onsubmit="return confirmSuspension(event)">
268262
@csrf
269263
@method('PATCH')
270264
<button type="submit" class="text-yellow-600 hover:text-yellow-500 text-sm">
@@ -294,7 +288,7 @@ class="text-blue-600 hover:text-blue-500 text-sm"
294288
</span>
295289
</h3>
296290
<p class="mt-1 max-w-2xl text-sm text-gray-500 dark:text-gray-400">
297-
These keys are currently suspended and cannot be used.
291+
These keys are permanently suspended and cannot be used or reactivated.
298292
</p>
299293
</div>
300294
</div>
@@ -332,22 +326,6 @@ class="ml-2 text-xs text-blue-600 hover:text-blue-500"
332326
</div>
333327
@endif
334328
</div>
335-
<div class="ml-4 flex items-center space-x-2">
336-
<button
337-
type="button"
338-
onclick="showEditSubLicenseModal({{ $subLicense->id }}, '{{ $subLicense->name }}', '{{ $subLicense->assigned_email }}')"
339-
class="text-blue-600 hover:text-blue-500 text-sm"
340-
>
341-
Edit
342-
</button>
343-
<form method="POST" action="{{ route('customer.licenses.sub-licenses.unsuspend', [$license->key, $subLicense]) }}" class="inline">
344-
@csrf
345-
@method('PATCH')
346-
<button type="submit" class="text-green-600 hover:text-green-500 text-sm">
347-
Unsuspend
348-
</button>
349-
</form>
350-
</div>
351329
</div>
352330
</div>
353331
</div>
@@ -697,5 +675,22 @@ function hideEditLicenseNameModal() {
697675
hideEditLicenseNameModal();
698676
}
699677
});
678+
679+
// Confirm suspension with warning about permanence
680+
function confirmSuspension(event) {
681+
const confirmed = confirm(
682+
'Are you sure you want to suspend this license?\n\n' +
683+
'WARNING: Once suspended, this license cannot be reactivated. ' +
684+
'You will need to create a new license instead.\n\n' +
685+
'This action is permanent and cannot be undone.'
686+
);
687+
688+
if (!confirmed) {
689+
event.preventDefault();
690+
return false;
691+
}
692+
693+
return true;
694+
}
700695
</script>
701696
</x-layout>

routes/web.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,5 @@
128128
Route::patch('licenses/{licenseKey}/sub-licenses/{subLicense}', [CustomerSubLicenseController::class, 'update'])->name('licenses.sub-licenses.update');
129129
Route::delete('licenses/{licenseKey}/sub-licenses/{subLicense}', [CustomerSubLicenseController::class, 'destroy'])->name('licenses.sub-licenses.destroy');
130130
Route::patch('licenses/{licenseKey}/sub-licenses/{subLicense}/suspend', [CustomerSubLicenseController::class, 'suspend'])->name('licenses.sub-licenses.suspend');
131-
Route::patch('licenses/{licenseKey}/sub-licenses/{subLicense}/unsuspend', [CustomerSubLicenseController::class, 'unsuspend'])->name('licenses.sub-licenses.unsuspend');
132131
Route::post('licenses/{licenseKey}/sub-licenses/{subLicense}/send-email', [CustomerSubLicenseController::class, 'sendEmail'])->name('licenses.sub-licenses.send-email');
133132
});

0 commit comments

Comments
 (0)