Redirect - Unauthorized

Hello Everyone,

I would like to redirect the user to the login page if the server response is “Unauthorized”.
I’m using node/ejs, I already have the browser component on the main layout and in the partial, there is a reference to the main layout browser component, below, the header of the partial:

<!-- Wappler include is="dmx-app" id="_referral" appconnect="local" jquery_slim_35="local" fontawesome_4="local" bootstrap4="custom" fontawesome_5pro="cdn" components="{dmxAutocomplete:{},dmxBootbox:{},dmxStateManagement:{},dmxBootstrap4TableGenerator:{},dmxBootstrap4Modal:{},dmxBootstrap4Alert:{},dmxDropzone:{},dmxPreloader:{},dmxNotifications:{},dmxSockets:{},dmxBootstrap4Tooltips:{},dmxFormatter:{},dmxBrowser:{}}" head-page="layouts/main_layout" -->

But when accessing the page:

How to make this redirect to the login page automatically if the response is “unauthorized”?

Thanks and have a great week!

You could set a Dynamic Event attached the Server Action based on the response. Ie, if unauthorised fire the Browser to redirect to the login. Or use a Security Restrict on the Action itself and specify the path to the login page there.

@Dave I was using security restrict already, just changed the Login URL and Forbidden URL on the Server Action! Thanks, mate! Brilliant!

Those fields within the Security Restrict often get overlooked.

You are very welcome Otavio, happy everything is working correctly. :slight_smile: