beyondcode / invoker-community

74 stars 2 forks source link

Invoker is missing the option to execute custom code (like user authorisation) before accessing models. #241

Closed webboty closed 3 years ago

webboty commented 3 years ago

Hi Team,

invoker as such in the current form can not really be used. It is clearly missing the functionality to authorise the user or do any specific action before accessing models.

For example we are using a multi tenant application where properties of the tenant are assigned via tenant_id on a GLOBAL SCOPE. For this to work we require parameters to be in the session that are created when the user logs in.

In short we need the option to execute code like to login the user before anything else is done, with any other models. Like:

$user = User::find(1);
Auth::login($user);

We installed the tinkerwell addon and added the code there, but the session is not transported over to the rest of the app ... so all models fail and invoker turns out to be absolutely useless

Cheers Tony


OS: darwin Invoker Version: 2.8.0 Laravel Version: 8.57.0 Local project: true PHP Binary: /usr/local/bin/php Route: /project/index?class=App%5CModels%5CMaterial&time=1630506453989&project=local-dRvrB5ny4KCeXUAKSFCaGa

sschlein commented 3 years ago

Hey, you can use the preload code feature in the project settings for that:

CleanShot 2021-09-02 at 12 38 51@2x

Feel free to reopen your issue if I have misunderstand your question :)

webboty commented 3 years ago

@sschlein thank you very much. This is what i needed. I totally missed that option. Works now. I was always checking the settings once the project was open and there was nothing there.