I successfully put together the login page, backend server action and redirect. I can get data of the logged in user with a user_data Server Action. And using the Server Connect, I want to redirect the user when she/he arrives on the page but not logged in. The user_data does send a 401 Unauthorize. I added a Browser Component and Dynamic Action on the Server Connect to redirect when Unauthorize – but it is not redirecting. It’s as if the Unauthorize event did not trigger.
This is my Server Action setup for retrieving user data.
Step 1 - Security Provider
Step 2 - Security Restrict – nothing in Permission, Login URL & Forbidden URL
Step 3 - Database Query – retrieving logged in user data. I do get this on the frontend
I checked this, but the redirect works fine for all the events.
What page are you working on exactly - is this a full page? Or a content page of a SPA site?
I am building a PHP site. I see that Wappler’s method is mostly like SPA with API backend. So I understand that the communications are mostly via XHR, and I am following this method when working with Wappler.
Currently I am learning how to work with Authentication using Wappler.
I also have another Server Connect for Logout. The logout works, with the Server Connect Dynamic Event, but I can’t get the redirect to work. I am using Success Event, with Browser Component and the Goto action.
Could it be something the Server Component Dynamic Events? It’s like these events are not triggering, for the user_data and the logout.
So is this a SPA content page you are testing the redirect - it's not really clear from your explanation?
Or is it a full page with html/head/body tags?
private_header.php - where I will have the navigation for logged in users, including logout button. This is what I shared above, where I have serverconnect1 for user_data and serverconnect2 for logout process
protected_pages.php - this will be other pages, where it will add private_header.php via PHP include
So is this a PHP include which you are testing? Or is it included on some page? Please explain this more detailed.
The issue from what i see is that the js include for the browser component is most probably missing from the page this PHP include is used on.
I am sorry if my explanation is rather vague. I am still trying to get used with all the terms. And thank you for being patient with me.
I believe private_header.php is a PHP include file. It does not have <head>, <meta> etc. But this is where I plan to use the Browser component for redirecting users, and protecting private pages.
Then I have test.php which has include() that calls private_header.php. I believe this is what you refer as Content Page. My initial plan is to have all the private pages include private_header.php.
With this setup, I tried moving the <script> for the browser component into private_header.php. But it gets removed upon file save.