Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

canSee implementation #17

Open
blackfyre opened this issue Feb 28, 2022 · 4 comments
Open

canSee implementation #17

blackfyre opened this issue Feb 28, 2022 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@blackfyre
Copy link

Our use case would require access control on select pages, any ideas on the feasibility?
A canSee callback, like how it is on nova resource fields, added to the tool instantiation seems like a good starting point.

@dniccum dniccum added enhancement New feature or request help wanted Extra attention is needed labels Mar 1, 2022
@dniccum
Copy link
Owner

dniccum commented Mar 1, 2022

Obviously this functionality doesn't exist at the moment. I hadn't planned on implementing this type of feature, but you are more than welcome to take this on and submit a PR.

@bluec
Copy link

bluec commented May 18, 2022

Hi, canSee is already implemented as this type of Authorization is a standard feature that all tools inherit from Laravel\Nova\Tool

You can use it like this, for example:

use Dniccum\NovaDocumentation\NovaDocumentation;

...

/**
 * Get the tools that should be listed in the Nova sidebar.
 *
 * @return array
 */
public function tools()
{
    return [
        // other tools
        (new NovaDocumentation)->canSee(function ($request) {
            return $request->user()->can('view documentation');
        }),
    ];
}

@blackfyre
Copy link
Author

@bluec That's true, however the ultimate scope is for individual pages instead of the complete tool.

@bluec
Copy link

bluec commented May 18, 2022

Ah my apologies I hadn't noticed that you wanted to restrict access to individual pages.

That is not possible and I don't know how easily it could be added. I've been looking at tweaking a few things in this tool but the lack of any in-depth developer documentation on Nova Tools makes it hard work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants