Logged In Check

What is the best method to go about checking that is a user is logged in or authorized to view a page?
I would like to avoid building the logic for every page. Is the best way to use Event Handlers in the Cloud Code section the best way to go?

Hello,

I believe the following video has an answer to your question:

Regards,
Mark

Thank you for that reference. I think I need to clarify a little more. Like in the Codeless shopping cart service Cloud Code API, a button click that is setup with 2 pieces of codeless items on a page, calls a whole subset of codeless items from that Cloud Code API. I am looking to do something like that for user session verification on secure pages. I would like do a similar process with a couple codeless items to call upon a Cloud Code API upon page enter that verifies a user login/session, and redirects them to the login page, just like the verification process used on the pages in the system container on page enter.

Hello @Walter_Figgeroa

What exactly do you want to secure?

For the cloud logic you can set permissions here

In a ui-builder app you can create a custom function and use it where you need

Regards,
Viktor

Hi @viktor.liablin,

Yes essentially something like that in the custom function. What I’m looking to do is in the picture below, and I would like to do it so all I need to do is insert the custom function or API, as to not have to rebuild this for ever page.
OnPageEnter

This would be as simple as creating a custom function with that logic and re-using it throughout your app.

Does it help?

Regards,
Mark

Going through the Logic tab in a container, and then the Functions tab on the right side to create a custom function, like what @viktor.liablin showed above makes sense, and I understand that, but the issue I seem to be running into is the inability to pull from the ‘App Data’ context block. The ‘App Data’ context block piece is not available in the custom functions, unlike when working on general logic in a page where you can pull app or page date. Is there a way to pull the app data into custom function?

Yes, it is possible, but only if you pass App Data as an argument into a custom function. For example:
UI Builder - ConsoleDemo - Backendless 2022-02-05 15-12-56

Then you can access app data as the function’s argument:

Finally, when you call the function, pass App Data:
UI Builder - ConsoleDemo - Backendless 2022-02-05 15-14-46

Regards,
Mark

Thank you for that, I also just watched the custom function video, I will spend some time playing around with the custom functions and see if I can make it work.