How to use a customized login page?

1
Hi, We are trying to use our own customized login page in our Mendix project. I searched the forum, and followed this: You can go to Project explorer-> Project -> Security and enable anonymous users and select a role for anonymous users. Project explorer-> Project -> Navigation: there you should set the page containing the login widget as default home page. My question is: After I login, the same login page still pops up.  1. When I select a role for anoymous user, can I choose any role?  2. In Navigation, should I set Default home page to this new customized login page? I think the new customized login page should be put in as "sign-in" page in Autentication Tab.  
asked
5 answers
5

Let's say that you create your login page in the module Login.

The new page that you created has the different elements on it from the widget menu under the header:

Then your form should look something like this:

In the Login module add a module role Guest, and set the permissions for the new login form (above) to hte new Guest module role.

In the security settings make sure to create a user role: Guest and add the Guest module role from the Login moduel to this user role.

Under the Anonymous users tab make sure the anonymous users are enabled and the role is set to Guest:

In the navigation add the LoginForm as role-based-home-page for the user role Guest:

Keep the default home page as the page where the user needs to go after login.

Now when you access the url of your app you are an anonymous user and therefore the role-based-home-page is shown: The newly created LoginForm from the Login module. After entering the correct credentials and signing in you are redirected to the default home page. 

If needed you can setup more role-based-home-pages, so that when e.g. an Admin logs in the user is redirected to the Admin home page and other users are redirected to the default home page.

I hope this explains how to create your custom login page correctly.

 

answered
0

 

I have this Visitor role for the customized login page. For other roles, I have Home.Home as default page.

 

Here is my enable anonymous :

 

The Visitor user role has Module roles assigned as:

System.User, Login.Visitor

 

 

Anything wrong?

Right now, it always lands on the customized login after I logged in.

 

 

 

answered
0

All looks good except you missed out one thing which I explained in the comment section above.

 

Try this,

1. Login as mxadmin, go to Account management page, select the testuser from grid assign him any app-specific role like administrator or user except for visitor.

2. Logout and try logging in with testuser. 

 

Explanation: You don't have to assign any user Account the Visitor/Guest role because any session created for a user accessing your application will have anonymous user role by default until they log in. So here testuser is anonymous/visitor when he sees the sign in page, but after signing in mendix check for the app role assigned to this user and redirects him to the respective page.

So in your case the check again directs him to visitor home page, changing the user role to anything other than visitor role will direct him to that role-specific homepage.

Hope this helps! Cheers! :)

answered
0

I am not sure if I get it.

First, login as mxadmin, from Mendix Modeler?

I have a customized login module, which has a module role 'Visitor'.

I have another System level User role, "Visitor". Which I should only assign it with User or Administrator role?

I tried and it didn't work for me

 

answered
0

You can try using a microflow as your home page. This would replace role based home pages and you can determine which page to show based on a check to see if the current user has the anonymous user role.

I usually do this when I don't want the anonymous home page to always open up for anonymous users.

 

The exclusive split checks if the $AnonymousUserRole object is empty or not.

answered