question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] If checkIfUserIsAdmin method returns false, always redirect to /home URL

See original GitHub issue

Bug report

What I did

update checkIfUserIsAdmin method to actually check whether the currently logged in user should be able to access backpack dashboard.

What I expected to happen

if the $user is not matched the criteria, redirected to homepage or backpack login page

What happened

keeps redirect to /home URL, even though that URL is not set in route.

What I’ve already tried to fix it

Updating the respondToUnauthorizedRequest inside the same CheckIfAdmin middleware.

However apparently all backpack-prefixed URL will always redirect to /home URL if checkIfUserIsAdmin method returns false and if there is actually a logged in user.

How can I change this /home redirection URL ?

Backpack, Laravel, PHP, DB version

When I run php artisan backpack:version the output is:

PHP VERSION:

PHP 7.4.5 (cli) (built: Apr 14 2020 16:17:34) ( ZTS Visual C++ 2017 x64 ) Copyright © The PHP Group Zend Engine v3.4.0, Copyright © Zend Technologies

LARAVEL VERSION:

v8.8.0@0bdd5c6f12cb7cb6644e484169656245af417735

LARAVEL VERSION:

v7.16.1@dc9cd8338d222dec2d9962553639e08c4585fa5b

BACKPACK VERSION:

4.1.25@23fb1ed5153d5465d49d2fe1ca265a5985c78877

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
mahasadhucommented, Oct 24, 2020

@iMokhles you’re right, I’ve made PRs to both of those changes.

1reaction
iMokhlescommented, Oct 18, 2020

@tabacitu this issue is from Laravel 7+ not only for Laravel 8+ as you mention in the doc

Read more comments on GitHub >

github_iconTop Results From Across the Web

Method for checking admin is redirecting me to main page ...
My question is how can I solve the problem so I can login normally, but if you aren't logged in you won't be...
Read more >
Redirections in HTTP - MDN Web Docs - Mozilla
Permanent redirects to preserve existing links/bookmarks after changing the site's URLs, progress pages when uploading a file, etc. Principle.
Read more >
How To Fix the HTTP 302 Error (5 Methods) - Kinsta
HTTP 302 codes are useful to temporarily redirect website users to another URL. If you're getting this error code, here are 5 ways...
Read more >
Redirect and Alias - Vue Router
A redirect means when the user visits /home , the URL will be replaced by / , and then matched as / ....
Read more >
How to Fix “Too Many Redirects” WordPress Error - DreamHost
How to Fix the “Too Many Redirects” Error in WordPress (13 Methods). URL redirection is necessary when pages have changed their addresses ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found