Browse Source

Fix created admin users not seeing settings button in sidebar (#503)

The sidebar hid Settings based on hardcoded role === 'user' instead of
the settings:read permission, and login set user state directly from the
response instead of re-fetching full auth status with permissions.
maziggy 3 months ago
parent
commit
974988c4f1

+ 1 - 0
CHANGELOG.md

@@ -6,6 +6,7 @@ All notable changes to Bambuddy will be documented in this file.
 
 
 ### Fixed
 ### Fixed
 - **"Power Off Printer" Option Not Gated by Control Permission** ([#500](https://github.com/maziggy/bambuddy/issues/500)) — The "Power off printer when done" checkbox in the print modal and the auto power off toggle in the bulk edit modal were accessible to all users regardless of permissions. Users without the `printers:control` permission can now no longer enable auto power off — the checkbox and tri-state toggle are disabled and visually dimmed.
 - **"Power Off Printer" Option Not Gated by Control Permission** ([#500](https://github.com/maziggy/bambuddy/issues/500)) — The "Power off printer when done" checkbox in the print modal and the auto power off toggle in the bulk edit modal were accessible to all users regardless of permissions. Users without the `printers:control` permission can now no longer enable auto power off — the checkbox and tri-state toggle are disabled and visually dimmed.
+- **Created Admin Users Can't See Settings Button** ([#503](https://github.com/maziggy/bambuddy/issues/503)) — The sidebar hid the Settings link based on a hardcoded `role === 'user'` check instead of the actual `settings:read` permission, so newly created admin users who had the permission still couldn't see the button. Also, after login the auth state was set directly from the login response instead of re-fetching the full auth status, which could miss permission data. Now uses `hasPermission('settings:read')` for the sidebar check and calls `checkAuthStatus()` after login to load the complete user state including permissions.
 
 
 ## [0.2.1b3] - 2026-02-23
 ## [0.2.1b3] - 2026-02-23
 
 

+ 2 - 2
frontend/src/components/Layout.tsx

@@ -220,8 +220,8 @@ export function Layout() {
     const result: string[] = [];
     const result: string[] = [];
     const seen = new Set<string>();
     const seen = new Set<string>();
 
 
-    // Determine if settings should be hidden (user role and auth enabled)
-    const hideSettings = authEnabled && user?.role === 'user';
+    // Determine if settings should be hidden (no settings:read permission)
+    const hideSettings = authEnabled && !hasPermission('settings:read');
     // Add items in stored order
     // Add items in stored order
     for (const id of sidebarOrder) {
     for (const id of sidebarOrder) {
       if (hideSettings && id === 'settings') continue;
       if (hideSettings && id === 'settings') continue;

+ 1 - 1
frontend/src/contexts/AuthContext.tsx

@@ -95,7 +95,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
   const login = async (username: string, password: string) => {
   const login = async (username: string, password: string) => {
     const response = await api.login({ username, password });
     const response = await api.login({ username, password });
     setAuthToken(response.access_token);
     setAuthToken(response.access_token);
-    setUser(response.user);
+    await checkAuthStatus();
   };
   };
 
 
   const logout = () => {
   const logout = () => {

File diff suppressed because it is too large
+ 0 - 0
static/assets/index-DFBcg8V9.js


+ 1 - 1
static/index.html

@@ -23,7 +23,7 @@
 
 
     <!-- Splash screens for iOS -->
     <!-- Splash screens for iOS -->
     <link rel="apple-touch-startup-image" href="/img/android-chrome-512x512.png" />
     <link rel="apple-touch-startup-image" href="/img/android-chrome-512x512.png" />
-    <script type="module" crossorigin src="/assets/index-BIJADXVl.js"></script>
+    <script type="module" crossorigin src="/assets/index-DFBcg8V9.js"></script>
     <link rel="stylesheet" crossorigin href="/assets/index-1Ts9jjQl.css">
     <link rel="stylesheet" crossorigin href="/assets/index-1Ts9jjQl.css">
   </head>
   </head>
   <body>
   <body>

Some files were not shown because too many files changed in this diff