4

I deployed my Laravel app with Laravel Nova on Laravel Forge. I installed Nova with a path repository, I have also Nova user. I replaced NovaServiceProvider Gate method like:

 Gate::define(‘viewNova’, function ($user) {

     return in_array($user->email, [

         ‘[email protected]’,

     ]);

 });

When I visiting page "/nova" there is login form but when I’m trying to log in with my existing user, it goes on 403 error page with the message “Sorry, you are forbidden from accessing this page

The only article I found is "Common problems when setting up Laravel Nova" on Medium.

Problem #2: there looks like my issue, but it's not. I think my issue is about the license, otherwise, I tried everything.

I have a solo Nova license and I have not to email support to ask them.

I have: Laravel 5.7 and Nova: 1.3.1

My question is: Should I buy the pro license? and why? Or what's the issue?

2
  • Are you sure that the user exists in your database? Try to access your server thorugh SSH and check it in tinker. Btw, also check that your password is hashed. Commented Feb 20, 2019 at 16:13
  • Btwm don't think the problem is your license. The package is a bunch of php classes, if you installed your dependencies and the code is downloaded then you are good to go. Commented Feb 20, 2019 at 16:14

2 Answers 2

10

This often occurs if you have deployed to a production environment and haven't set up your Gate guard yet. Or have a cached config, or are signed in as an email that isn’t whitelisted.

Ensure you add your emails like so:

protected function gate()
{
    Gate::define('viewNova', function ($user) {
        return in_array($user->email, [
            '[email protected]',
            '[email protected]',
        ]);
    });
}

to app/Providers/NovaServiceProvider.php

Further to that - some housekeeping items to remember:

php artisan nova:install
php artisan optimize:clear

Clearing [config] caches can usually clear up bumps along the road.

Sign up to request clarification or add additional context in comments.

Comments

1

I believe your issue (unless it's not actually the code running), is due to the and characters surrounding the email address you're authorizing and what's being passed to define(). Try ' or " instead - PHP understands those, not the previous characters.

 Gate::define('viewNova', function ($user) {
     return in_array($user->email, [
         '[email protected]',
     ]);
 });

This is a common mistake if you're copying / pasting from text editors like Microsoft Word, or copying from online sources!

1 Comment

Thanx, I have no idea why are incorrect symbols in my question, but I have correct symbols in my code. Updated info about my issue is that when I'm defining my environment as local, it's working good, otherwise there is same. So I'm sure it's a license issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.