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

Authorization not working, backpack #360

Closed
tmindiashvili1 opened this issue Nov 9, 2018 · 15 comments
Closed

Authorization not working, backpack #360

tmindiashvili1 opened this issue Nov 9, 2018 · 15 comments

Comments

@tmindiashvili1
Copy link

I use laravel backpack and override Telescope Authorize Middleware class, As shown on the photo. But backpack_auth()->guest(); always true, but I have already logged in.

test12312

I use backpack guard.

guard

@tmindiashvili1
Copy link
Author

$user = \Auth::guard('backpack'); user null, but I have already logged in.

sessionguard

@paras-malhotra
Copy link
Contributor

paras-malhotra commented Nov 9, 2018

This is unrelated to the laravel/telescope repo. You should report this issue to the backpack repo.

@tmindiashvili1
Copy link
Author

This is unrelated to the laravel/telescope repo. You should report this issue to the backpack repo.

default authorization not working too

@paras-malhotra
Copy link
Contributor

In that case you can file a separate issue with the code and expected result

@tmindiashvili1
Copy link
Author

In that case you can file a separate issue with the code and expected result

12312dsa

@paras-malhotra
Copy link
Contributor

What is the issue here?

@tmindiashvili1
Copy link
Author

What is the issue here?

I authorized other user but laravel telescope show anyway

@paras-malhotra
Copy link
Contributor

The default authorization method looks like this:

    /**
     * Configure the Telescope authorization services.
     *
     * @return void
     */
    protected function authorization()
    {
        $this->gate();

        Telescope::auth(function ($request) {
            return app()->environment('local') ||
                   Gate::check('viewTelescope', [$request->user()]);
        });
    }

You need to override this method in your TelescopeServiceProvider and remove app()->environment('local') if you only want the Gate check like so:

    /**
     * Configure the Telescope authorization services.
     *
     * @return void
     */
    protected function authorization()
    {
        $this->gate();

        Telescope::auth(function ($request) {
            return Gate::check('viewTelescope', [$request->user()]);
        });
    }

@tmindiashvili1
Copy link
Author

The default authorization method looks like this:

    /**
     * Configure the Telescope authorization services.
     *
     * @return void
     */
    protected function authorization()
    {
        $this->gate();

        Telescope::auth(function ($request) {
            return app()->environment('local') ||
                   Gate::check('viewTelescope', [$request->user()]);
        });
    }

You need to override this method in your TelescopeServiceProvider and remove app()->environment('local') if you only want the Gate check like so:

    /**
     * Configure the Telescope authorization services.
     *
     * @return void
     */
    protected function authorization()
    {
        $this->gate();

        Telescope::auth(function ($request) {
            return Gate::check('viewTelescope', [$request->user()]);
        });
    }

$request->user() is null, and why ?

@paras-malhotra
Copy link
Contributor

paras-malhotra commented Nov 9, 2018

$request->user() is null, and why ?

Refer #294 (comment) and #294 (comment)

@tmindiashvili1
Copy link
Author

Refer #294 (comment) and #294 (comment)

$request->user('my_guard_name') But it's still the same null

@themsaid
Copy link
Member

Can't replicate this, authentication with custom guard is working. and $request->user('my_guard_name') returns the logged in user.

@tmindiashvili1
Copy link
Author

Can't replicate this, authentication with custom guard is working. and $request->user('my_guard_name') returns the logged in user.

null returns ((

@themsaid
Copy link
Member

closing since it doesn't seem to be Telescope related.

@meeprakash25
Copy link

$request->user() is null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants