BookStack icon indicating copy to clipboard operation
BookStack copied to clipboard

Query regarding hasSystemRole() and custom roles

Open FideliusFalcon opened this issue 2 months ago • 1 comments

Attempted Debugging

  • [x] I have read the debugging page

Searched GitHub Issues

  • [x] I have searched GitHub for the issue.

Describe the Scenario

Hi,

I'm working on a custom theme and trying to show specific navigation links based on user roles.

I've found that hasSystemRole() works perfectly for the default admin role, but it consistently fails for other roles, including the default 'Editor' and any custom roles I create.

Here is a snippet of my test code from a custom header file, which demonstrates the issue:

{{-- This link displays correctly when the user is an admin --}}
@if(auth()->user()->hasSystemRole('admin'))
    <li>
        <a href="#" role="menuitem" class="icon-item">
            @icon('lock') <div>Admin Link</div>
        </a>
    </li>
@endif

{{-- This link does NOT display, even when the user has the 'Editor' role --}}
@if(auth()->user()->hasSystemRole('editor'))
    <li>
        <a href="#" role="menuitem" class="icon-item">
            @icon('edit') <div>Editor Link</div>
        </a>
    </li>
@endif

{{-- This link also does NOT display for my custom 'Test' role --}}
@if(auth()->user()->hasSystemRole('test'))
    <li>
        <a href="#" role="menuitem" class="icon-item">
            @icon('info') <div>Test Link</div>
        </a>
    </li>
@endif

My question is: Is the hasSystemRole() method intended to be used with roles other than admin? Given that it works for admin, I'm trying to understand what might be preventing it from recognizing other default and custom roles.

Thanks for your great work on BookStack!

Exact BookStack Version

v25.07.20250804

Log Content


Hosting Environment

Docker image: linuxserver/bookstack:25.07.20250804

FideliusFalcon avatar Oct 08 '25 08:10 FideliusFalcon