Restricting user authentication based on criterias

I am using the plugin RainLab.User in its latest version (3+) to handle registration and authentication.

I have two themes that can use the login page.
the 1st theme is for a user type 1;
the 2nd theme is for a user type 2;

Each theme has its own login page.

I want to restrict user authentication in each theme based on the user lets say his user group belonging. How can i go about that ?

Im looking at doing some magic in the function onEnd() in each login page to test their user group
belonging.

Is there any other better approach to that ?

I would probably handle this in Twig, using a partial inside the layout

{% if user.type1 %}
    {% do redirect('type1/login/page') %}
{% endif %}

And then repeat something similar for type 2

1 Like

great idea.

I used this in the app layout

{% if user and false == user.inGroup('mygroup') %}
    {% do redirect('/403') %}
{% endif %}
1 Like