Skip to content

Commit e892901

Browse files
committed
feat: add license limit exceeded notification for user registration
1 parent 0706452 commit e892901

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

resources/lang/en/pages/auth/register.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
'title' => 'Assign user role failed',
5151
'body' => 'Please ensure you have already run the migration and imported the default data.',
5252
],
53+
'license_limit_exceeded' => [
54+
'title' => 'User Limit Reached',
55+
'body' => 'You have reached the maximum number of users allowed by your current license. Please upgrade your plan to add more users.',
56+
],
5357
],
5458

5559
];

resources/lang/zh_TW/pages/auth/register.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
'title' => '分配用戶角色失敗',
5151
'body' => '請確保您已經運行遷移並導入默認數據。',
5252
],
53+
'license_limit_exceeded' => [
54+
'title' => '用戶限制已達到',
55+
'body' => '您已達到當前許可證允許的最大用戶數。請升級您的計劃以添加更多用戶。',
56+
],
5357
],
5458

5559
];

src/CmsPanelProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ protected function configureCmsPanel(Panel $panel)
100100
SubstituteBindings::class,
101101
DisableBladeIconComponents::class,
102102
DispatchServingFilamentEvent::class,
103+
CmsMiddleware\LicenseCheck::class,
103104
CmsMiddleware\SetUpPoweredBy::class,
104105
];
105106
$authMiddleware = [
106-
CmsMiddleware\LicenseCheck::class,
107107
CmsMiddleware\CmsAuthenticate::class,
108108
CmsMiddleware\UserPreference::class,
109109
];

src/Filament/Pages/Auth/Register.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use SolutionForest\InspireCms\Facades\PermissionManifest;
2020
use SolutionForest\InspireCms\Helpers\AuthHelper;
2121
use SolutionForest\InspireCms\InspireCmsConfig;
22+
use SolutionForest\InspireCms\Licensing\LicenseManager;
2223
use SolutionForest\InspireCms\Models\Contracts\User;
2324
use Spatie\Permission\Traits\HasRoles;
2425

@@ -83,6 +84,12 @@ public function mount(): void
8384

8485
public function register(): ?RegistrationResponse
8586
{
87+
if (! app(LicenseManager::class)->canCreateUser()) {
88+
$this->getLicenseLimitNotification()?->send();
89+
90+
return null;
91+
}
92+
8693
try {
8794
$this->rateLimit(2);
8895
} catch (TooManyRequestsException $exception) {
@@ -267,6 +274,14 @@ protected function getAssignRoleFailedNotification(): ?Notification
267274
->danger();
268275
}
269276

277+
protected function getLicenseLimitNotification(): ?Notification
278+
{
279+
return Notification::make()
280+
->title(__('inspirecms::pages/auth/register.messages.license_limit_exceeded.title'))
281+
->body(__('inspirecms::pages/auth/register.messages.license_limit_exceeded.body'))
282+
->danger();
283+
}
284+
270285
public function getTitle(): string | Htmlable
271286
{
272287
return $this->isAlreadyInitialized ? __('inspirecms::pages/auth/register.title.installed') : __('inspirecms::pages/auth/register.title.not_installed');

0 commit comments

Comments
 (0)