previous screen skips OnInitialize?

Hi,
In our application we check for specific user permissions in the OnInitialize. The security requirements are not just limited to role based security, we also query a custom table which holds more specific business requirements to decide screen access.

For example, this CheckUserPermission action is part of the OnInitialize of the Reservations screen.
In case CanViewReservations is false, we redirect to invalid permissions.




So, in case our database tells us viewing reservations is not allowed for GetUserId(), we redirect. But here's the issue :

The InvalidPermissions page has a 'Go Back' button which redirects to (Previous Screen). 

After having redirected, the previous screen is, of course, the screen we just got rejected from. 

However, this time, the user succesfully lands on that reservations page. Which is not supposed to happen.

Doesn't the OnInitialize rerun when we go back to Previous Screen? 
The decision for 'Allowed' was false, and I would expect it to cause a new redirect to InvalidPermissions again. (Yes, that does make the Go Back button quite pointless in this scenario, but that's off topic)




here's the successfull landing on the Reservations page after going back via Previous Screen
I can get the same result by using the browser's Go Back button, so just changing the outsystems' button is not a sufficient enough fix. We truely rely on that OnInitialize to decline access via the redirect, is that not a good practise?


Hi! 

Probably not. 

In case of sensible data the initial tests are just for UI, the action that is going to update the data must recheck the permissions again before complete the update and act accordingly. 

This is true also for data that can be changed by more than one person , before change it the action should check if it is the same it was when the screen was shown. 

Hope this helps you

Graça

Hi,

Just made a test in my personal environtment and I cannot replicate your issue, in my case the button returns and runs the OnInitialize of the previous screen again and I end up in the same place (your expected result). So yours is indeed an odd behavior... Can you provide the OML somehow?

Cheers,
Paulo

Hi Gwin,

Instead of setting Onclick to Previous screen add a button click event and in that set a redirect to other screen .

Seems like Previous screen navigation works like back button of the browser and it pulls the information back from the cache. however redirect to other screen is like reloading of the page

Best Regards

Devendra

Hi,

Instead of passing "Previous Screen" As Destination, try to pass the "Reservations" screen as a destination.

Regards,

Ramesh Godara

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.