Controller, $kirby->user() doesn't work

Hi :slight_smile: I am still working on the migration of a Kirby plugin from version 2 to 4.

I have an admin Kirby-User, and am logged in with it. I am trying to check in my controller whether the logged-in user is an admin or not. However, this does not work because the user in the Kirby object is null (see Screenshot). What is going wrong?

My Controller:

return function ($site, $page, $kirby) {

    if ($kirby->user()->isAdmin()) {
     
    }

    return [
        'data' => $data,
    ];
}

That code should work

Still, Iโ€™d personally do $kirby->user()?->isAdmin() so that you donโ€™t get an error when a user is not logged in at all.