How to redirect Users/Admin to their specific Homepage?

I've created 2 Web Screens, one for the anonymous and users (Homepage) and another for the App Admin/StoreManager (HomepageSM). The in the MainFlow, I've put the Login Web Screen after the Entry, and the changed the Logic of the Login Action to as follows on the image below:


In fact, I want:

- When somebody enters in the App, the Login Web Screen appears;

- If He does the Login for Admin(Store Manager) it redirects to the HomepageSM;

- If He pretends to stay anonyous or make his registered login it redirects to the Homepage.


I got no errors on ServiceStudio, but when i try to load the page (on the browser), it sends this warning:

Thanks in advance,

ruipmoura



Hello Rui,

At first, I can't find anything unusual with your Login Action.

What page is giving this problem? The Login page (entering it rise this), or after login?
If this happens AFTER the login, happens to any user or only for the normal users or only for the Admin users?
Also, do you have any Destination at the end of the preparation on any of the pages to where you are redirecting the user after login?

Cheers.

P.S. The two pages are inside the same Module than the Login page? If not, did you refreshed the dependences?

thanks for the quick reply Eduardo!

It happens when I click to Open in Browser (entering the Login page). Here's my MainFlow:


And no, I don't have any Destination in both Preparations (Homepage and HomepageSM).

Both of the Pages are in the same Module of the Login Page, the Web Responsive one.


Thanks, 

ruipmoura


Ok,

Now I understand your problem. It happens AFTER the first time you make the login successfully, because of the code in the preparation of the Login page:

As you can see, if you are logged in already, the Login page will automatically redirect you to the landing page of your application (GetOwnerURLPath). And this will create an infinite looping that the browser can detect and stop the loading with the warning you are seeing.

My suggestion is to do a little differently.
Instead of using the Login page as the default landing page, create an empty Home with a preparation that redirects (in the preparation) to the correct page according to the user (instead of doing this in the Login). Make the page available only for the roles that can access the application.

This will make the Login page to be called if the user is not logged yet, and after login, it will be automatically redirected to the correct page. Also, after this, the user can open the application without having to pass by the login page every time he opens the application in a valid session.

Cheers.

Eduardo,

First of all, thanks for the explanation about the cause of such error on the Browser.


I accept your suggestion on how to redirect the users for their Homepage, but I would ask an extra feature:

I would like to have a button in the Entry page, next to Login, allowing Anonymous users only to browse the Products Page.

I've already tried to add more content to this Entry Page, but everytime I open the application it redirects me to the Login screen.


Best Regards,

ruipmoura

Solution

Hi Rui.

You can't. Once a page has defined a set of Roles that can access it, and anonymous is not between them, any person that is not logged will have to login first to see this page.

Your options are:
1. A different page for anonymous, and if the person wants to make login it clicks the login link.
2. An anonymous page where you control what can be seen using the IF widget (for example). For things only a registered and/or manager can see, you wrap them in an IF and use the CheckRegisterRole() and/or CheckManagerRole() (where Manager is your role name), and so only them will have this in the page when accessing the page.

Any of these approaches suit your needs? 

Cheers.

Solution

Eduardo,

I've just came to the conclusion that would be convenient to have two modules, one for the Anonymous and registered Users, and another for the Store Manager, which one with its own proper HomePage.

However, I will keep this module only, and I will accept your 1st option - I will set the HomePage for every type of Users:

- Anonymous Users will have the chance to browse the products;

- if a registered Users logins, it will be kept on the Products page and will have access to more features.

- if Store Manager logins, she will be redirected to the StoreManagment Page.


This challenge is solved ;)

Many thanks Eduardo,

Best Regards, 

ruipmoura