Skip to content

Added link to user-creatable-servers, for automatic creation of User Resource Limits.#131

Closed
TheOriginalCER06 wants to merge 2 commits intopelican-dev:mainfrom
TheOriginalCER06:register-link-ucs
Closed

Added link to user-creatable-servers, for automatic creation of User Resource Limits.#131
TheOriginalCER06 wants to merge 2 commits intopelican-dev:mainfrom
TheOriginalCER06:register-link-ucs

Conversation

@TheOriginalCER06
Copy link
Copy Markdown

@TheOriginalCER06 TheOriginalCER06 commented May 9, 2026

Not tested without both plugins.

Made for own use, works for me, thought it might be good to contribute back to the community.

Summary by CodeRabbit

  • New Features

    • Registration can be capped at a configurable maximum; signups are automatically closed when reached
    • Admin settings added to configure max users and default per-user resource allocations
  • Documentation

    • Expanded guidance for configuring registration limits and default resource assignments via the UI
  • Localization

    • Added a user-facing “registration closed” message when the user cap is reached
  • Chores

    • Plugin metadata updated (author and version)

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1ebbaed5-61b2-4fac-b8aa-89e72ec25794

📥 Commits

Reviewing files that changed from the base of the PR and between e15b739 and c344058.

📒 Files selected for processing (2)
  • register/src/Filament/Pages/Auth/Register.php
  • register/src/RegisterPlugin.php
🚧 Files skipped from review as they are similar to previous changes (2)
  • register/src/RegisterPlugin.php
  • register/src/Filament/Pages/Auth/Register.php

📝 Walkthrough

Walkthrough

This pull request adds a configurable maximum user registration cap and automatic initialization of default per-user resource limits on signup. It includes a new Filament settings UI that allows administrators to configure registration limits and default CPU, memory, disk, and server limits, with settings persisted to a PHP config file.

Changes

Registration Limit Cap and Auto Resource Limits

Layer / File(s) Summary
Configuration and Language Schema
register/config/register.php, register/lang/en/messages.php
Config file defines max_users and default resource limits (all initialized to 0); language file provides registration_closed message for users when capacity is reached.
Registration Limit Enforcement
register/src/Filament/Pages/Auth/Register.php
mount() and handleRegistration() overrides check configured max_users limit; abort with 403 during page load, throw ValidationException during submission. After user creation, createDefaultUserResourceLimits() initializes resource limit records with configured defaults when the model and table exist.
Settings UI and Config Persistence
register/src/RegisterPlugin.php
Plugin implements HasPluginSettings with getSettingsForm() providing Filament schema for registration and resource limit inputs; saveSettings() handles submission and error notifications; persistSettingsToConfig() generates and writes config/register.php under the plugin path using file_put_contents(..., LOCK_EX), updates runtime config, and clears cached config when necessary.
Documentation and Manifest Updates
register/README.md, register/plugin.json
README documents max user cap and auto resource limit features plus configuration UI guidance; plugin version bumped to 1.0.1 and author updated to include TheOriginalCER06.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant RegisterPage
  participant UserDB
  participant UserResourceLimitsDB
  Client->>RegisterPage: GET mount()
  RegisterPage->>UserDB: count users (check max_users)
  alt limit reached
    RegisterPage->>Client: 403 (registration_closed)
  else
    Client->>RegisterPage: POST registration data
    RegisterPage->>UserDB: verify limit (lock optional)
    alt limit reached
      RegisterPage->>Client: ValidationException (registration_closed)
    else
      RegisterPage->>UserDB: create user
      RegisterPage->>UserResourceLimitsDB: updateOrCreate defaults
      RegisterPage->>Client: return created user
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • lajczi

Poem

🐰 A cap on users, limits set with care,
Resources shared in equal measure fair,
Config saved through Filament's gentle hand,
Registration flows across the land!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: adding integration with user-creatable-servers for automatic User Resource Limits initialization, which is demonstrated throughout the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@register/src/Filament/Pages/Auth/Register.php`:
- Around line 68-96: The current registration cap check in
throwIfRegistrationLimitReached/abortIfRegistrationLimitReached is non-atomic
and can be bypassed under concurrency because you read count() before creating a
user; change handleRegistration so the check and the actual user creation occur
inside a serialized critical section (e.g., a DB transaction with a table/row
lock or a DB advisory lock) to guarantee atomicity: acquire the lock, re-check
the count via getUserModel()::query()->lockForUpdate() or an advisory lock,
abort/throw if limit reached, then perform the parent::handleRegistration($data)
create and call createDefaultUserResourceLimits($user) before releasing the
lock; keep mount()/abortIfRegistrationLimitReached as a UX-only precheck.

In `@register/src/RegisterPlugin.php`:
- Around line 101-107: The config assignment in RegisterPlugin.php does not
guard against negative integers because UI checks can be bypassed; update the
$config population (the array keys 'max_users', 'default_cpu', 'default_memory',
'default_disk', 'default_server_limit' in the RegisterPlugin class) to clamp
each value to a non-negative integer before persisting (e.g., cast to int then
apply max(0, value) or equivalent) so all stored values are guaranteed >= 0.
- Around line 97-119: persistSettingsToConfig writes to the config file
($configPath) but doesn't clear Laravel's cached config; after the successful
file_put_contents write (i.e., after confirming it didn't return false) call the
config cache clear operation (e.g., invoke cache('config')->clear() or an
equivalent Artisan config clear) so subsequent calls to config('register.*')
reflect the new values; place this call immediately after the write succeeds and
before the method finishes, and keep it guarded so failures still throw the
existing RuntimeException.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3b266dd4-c868-4c25-91bb-5d0737b27c4c

📥 Commits

Reviewing files that changed from the base of the PR and between 587828b and e15b739.

📒 Files selected for processing (6)
  • register/README.md
  • register/config/register.php
  • register/lang/en/messages.php
  • register/plugin.json
  • register/src/Filament/Pages/Auth/Register.php
  • register/src/RegisterPlugin.php
📜 Review details
🧰 Additional context used
🪛 LanguageTool
register/README.md

[grammar] ~12-~12: Use a hyphen to join words.
Context: ...` is installed ## Integration with User Creatable Servers This plugin can autom...

(QB_NEW_EN_HYPHEN)

🔇 Additional comments (4)
register/config/register.php (1)

3-9: Config keys and defaults look consistent.

The new defaults align with the registration/resource-limit settings introduced in this PR.

register/lang/en/messages.php (1)

3-5: Translation string is clear and correctly scoped.

Message text is suitable for the new max-user registration guard.

register/plugin.json (1)

4-5: Manifest metadata update looks good.

Author/version updates are coherent with the feature additions in this PR.

register/README.md (1)

9-23: README changes are aligned with behavior.

The new docs accurately describe max_users and default resource-limit provisioning for new users.

Comment thread register/src/Filament/Pages/Auth/Register.php
Comment thread register/src/RegisterPlugin.php
Comment thread register/src/RegisterPlugin.php
@TheOriginalCER06
Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 9, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Boy132
Copy link
Copy Markdown
Member

Boy132 commented May 9, 2026

I don't see a reason for a user limit on the registration.

Defaults for newly created users are fine, but this should go in the user-creatable-servers plugin and apply for all new users.

@TheOriginalCER06
Copy link
Copy Markdown
Author

Limit is because it might be accidentally exposed to the whole internet, and when allowing new user registration you might not want them to use all your available resources. (A safety guard for the average user).

Agree, it was just my first thought. It makes a lot more sense for the default to be there. Might move in the future, but currently I don't have the need or time to change this.

You can close this, if you want.

@Boy132 Boy132 closed this May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants