chris
October 11, 2024, 2:09pm
#1
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 ?
daft
October 14, 2024, 9:20pm
#2
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
chris
October 15, 2024, 9:54am
#3
great idea.
I used this in the app layout
{% if user and false == user.inGroup('mygroup') %}
{% do redirect('/403') %}
{% endif %}
1 Like
snipi
October 17, 2024, 8:49pm
#4
just small reminder to set proper status code, because you wont get indexed redirects etc.
{% do redirect(ā/403ā, 403) %}
chris
October 18, 2024, 7:28am
#5
good point, thanks @snipi
chris
October 18, 2024, 1:18pm
#6
conversely, Iād like to add a specific group when a user registers in one of the site of my multisite setup, how can I achieve that ?
I can listen to the event rainlab.user.register
but it will fire every time a user register. and i want to control it only in a particular website attached to a theme because other site within can also register user.