From 6287054a2a0c4f5821f67344aa33a015bac7a47b Mon Sep 17 00:00:00 2001 From: jwed Date: Mon, 17 Aug 2026 18:27:40 -0400 Subject: [PATCH] Guest Wi-Fi card can say whether it is set up MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit configured() answers the three settings payload() needs as one question, so the permission screens can say "granted, but not switched on yet" instead of leaving a grantee staring at an unchanged home page. The operator granted this key to two groups in production and saw nothing (2026-08-17); the card had simply never been enabled and had no SSID. The card's own behaviour is unchanged — it still self-hides, like every other card — the sentence is said where somebody is deciding who gets the key. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01RDA3fQbsa3gaHCFoV1Q8Gg --- src/Http/Controllers/GuestCardController.php | 20 ++++++++++++++++++++ src/UnifiServiceProvider.php | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/src/Http/Controllers/GuestCardController.php b/src/Http/Controllers/GuestCardController.php index d32ef18..0bd0f58 100644 --- a/src/Http/Controllers/GuestCardController.php +++ b/src/Http/Controllers/GuestCardController.php @@ -17,6 +17,26 @@ use Illuminate\Routing\Controller; */ class GuestCardController extends Controller { + /** + * Is this card set up enough to ever appear? + * + * The three things payload() needs, asked as one question, so the permission + * screens can say "granted, but not configured yet" instead of leaving + * somebody staring at a home page wondering what they got wrong. The + * operator granted this key to two groups in production and saw nothing + * (2026-08-17); the card was simply never switched on. + * + * Note the third clause: last_password is written ONLY by + * unifi:rotate-passwords, so a school that sets a static guest password by + * hand and never rotates has no card and no obvious reason why. + */ + public static function configured(): bool + { + return (bool) Setting::get('unifi.guest_card.enabled') + && trim((string) Setting::get('unifi.guest_card.ssid', '')) !== '' + && filled(Setting::get('unifi.password_rotation.last_password')); + } + /** Payload shared by the card resolver and the poll endpoint. */ public static function payload(): ?array { diff --git a/src/UnifiServiceProvider.php b/src/UnifiServiceProvider.php index f719f4a..ef80f42 100644 --- a/src/UnifiServiceProvider.php +++ b/src/UnifiServiceProvider.php @@ -46,6 +46,10 @@ class UnifiServiceProvider extends ServiceProvider fn (\App\Models\User $user) => \Dashboard\Unifi\Http\Controllers\GuestCardController::resolve($user), 'The guest network name, current password, and a join QR code — updates automatically when the password rotates.', permission: 'unifi.guest_wifi', + // So the permission screens can say "granted, but not switched + // on yet" rather than leaving a grantee staring at a home page + // with nothing new on it. + configured: fn () => \Dashboard\Unifi\Http\Controllers\GuestCardController::configured(), ); } catch (\Throwable) { // Older shell without the card registry — skip.