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

[Bug]: onEventClick does not pass Policy because action is null #36

Open
juienpro opened this issue Sep 23, 2024 · 3 comments · May be fixed by #66
Open

[Bug]: onEventClick does not pass Policy because action is null #36

juienpro opened this issue Sep 23, 2024 · 3 comments · May be fixed by #66
Labels
bug Something isn't working

Comments

@juienpro
Copy link

What happened?

When I set $defaultEventClickAction, it does not pass policy in onEventClick in HandlesEventClick.php.

I think that the default action should be loaded before $this->authorize.

How to reproduce the bug

 public function onEventClick(array $info = [], ?string $action = null): void
    {
        \Log::debug('action: '.$action);
        try {
            $model = data_get($info, 'event.extendedProps.model');
            $key = data_get($info, 'event.extendedProps.key');
            \Log::debug('toto');
            if ($model && $key) {
                $this->resolveEventRecord(
                    data_get($info, 'event.extendedProps.model'),
                    data_get($info, 'event.extendedProps.key'),
                );

                \Log::debug('toto2');
                \Log::debug(print_r($action, true));
                $this->authorize(match ($action) {
                    'edit' => 'update',
                    default => $action,
                }, [$this->eventRecord]);

                \Log::debug('toto3');
                $action ??= data_get($info, 'event.extendedProps.action', $this->getDefaultEventClickAction());
                if ($action) {
                    $this->mountAction($action, [
                        'event' => data_get($info, 'event', []),
                    ]);
                }
            }
        } catch (AuthorizationException $e) {
            return;
        }
    }

The debug message toto3 is never displayed, while toto2 is shown. Except if I miss something, It's likely that the line:

$action ??= data_get($info, 'event.extendedProps.action', $this->getDefaultEventClickAction());

should be put before $this->authorize.

Package Version

1.7

PHP Version

8.2.0

Laravel Version

11.0.0

Which operating systems does with happen with?

Linux

Notes

No response

@juienpro juienpro added the bug Something isn't working label Sep 23, 2024
@cirrion-software
Copy link

Same issue. Has this been resolved

@lukas-frey
Copy link
Contributor

Not yet. I'll fix it in the next release. If you need it fast, feel free to open a PR and I'll merge it asap.

@heloufir
Copy link

Not yet. I'll fix it in the next release. If you need it fast, feel free to open a PR and I'll merge it asap.

any news?

sparksp added a commit to sparksp/GuavaCZ-calendar that referenced this issue Jan 25, 2025
@sparksp sparksp linked a pull request Jan 25, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants