? ? ? Pending

User tests: Successful: Unsuccessful:

avatar carlitorweb
carlitorweb
13 Apr 2018

Summary of Changes

This PR adds a restriction in case the user registration is needed, only for a group of mail domain and/or TLD, or block for a group of mail domain and/or TLD.

Testing Instructions for the option "Whitelist"

  1. Go to the configs in the user manager
  2. Select a Whitelist option in the field Email/TLD Restriction. Fill the field Email/TLD List and save.
  3. Go to the frontend/backend, and try to register/edit a user with a different domain/TLD than the field Email/TLD List. Also, check this is valid for the Edit Account option in the top right corner of the admin area.
  4. Go to the frontend/backend, and try to register/edit a user with a domain/TLD which is on the list Email/TLD List. Also, check this is valid for the "Edit Account" option in the top right corner of the admin area.

Expected result

An error message will show up, saying, "Your mail domain xxx is not allowed", refusing registration in case you try to register with a different domain/TLD. Or the new registration is accepted otherwise.

Testing Instructions for the option "Blacklist"

  1. Go to the configs in the user manager
  2. Select a Blacklist option in the field Email/TLD Restriction. Fill the field Email/TLD List and save.
  3. Go to the frontend/backend, and try to register/edit a user with a different domain/TLD than the field Email/TLD List . Also, check this is valid for the Edit Account option in the top right corner of the admin area.
  4. Go to the frontend/backend, and try to register/edit a user with a domain/TLD which is on the list Email/TLD List. Also, check this is valid for the Edit Account option in the top right corner of the admin area.

Expected result

An error message will show up, saying, "Your mail domain xxx is not allowed", refusing registration in case you try to register with a domain/TLD, which it is within of the field Email/TLD List. Or the new registration is accepted otherwise.

Documentation Changes Required

New com_users config added.

avatar carlitorweb carlitorweb - open - 13 Apr 2018
avatar carlitorweb carlitorweb - change - 13 Apr 2018
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 13 Apr 2018
Category Administration com_users Language & Strings Front End
avatar SharkyKZ
SharkyKZ - comment - 13 Apr 2018

If this feature is approved, it should be improved to accept multiple domains and to set whether domains are allowed or banned.

avatar brianteeman
brianteeman - comment - 13 Apr 2018

yes it should be a - a whitelist/blacklist feature

avatar alikon
alikon - comment - 13 Apr 2018

is this a core feature ?

avatar Bakual
Bakual - comment - 13 Apr 2018

is this a core feature ?

Imho no. I'm quite sure there exist already 3rd party plugins which do that fine and the use case is quite limited.

avatar brianteeman
brianteeman - comment - 13 Apr 2018

I looked and didnt see any

Enhanced to have a list of allowed and disallowed domains could be quite useful

avatar ot2sen
ot2sen - comment - 13 Apr 2018

Could be useful in core. But there are free extensions doing feature like this. For example:
https://extensions.joomla.org/extensions/extension/access-a-security/site-access/domainrestriction/

avatar brianteeman
brianteeman - comment - 13 Apr 2018

i missed that

avatar carlitorweb
carlitorweb - comment - 13 Apr 2018

I'm going to implement the Whitelis/Blacklist. In my opinion, is useful and necessary this featured inside core.

avatar carlitorweb carlitorweb - change - 13 Apr 2018
Labels Added: ? ?
avatar carlitorweb
carlitorweb - comment - 13 Apr 2018

This featured, It is normal in all kinds of scenarios, such as user registration. I do not think you should install another extension, to have it enabled

avatar joomla-cms-bot joomla-cms-bot - change - 14 Apr 2018
Category Administration com_users Language & Strings Front End Administration com_users Language & Strings Front End Modules
avatar joomla-cms-bot joomla-cms-bot - change - 14 Apr 2018
Category Administration com_users Language & Strings Front End Modules Administration com_users Language & Strings Front End
avatar carlitorweb
carlitorweb - comment - 14 Apr 2018

Sorry for this, did wrong here

avatar stutteringp0et
stutteringp0et - comment - 15 Apr 2018

The extension @ot2sen mentioned is mine - I originally wrote it for a school, to limit registrations to employees using a valid school domain. Later I expanded it on user feature requests.

I find that most people use it to blacklist domains, but it can white/black list TLD, Domain, and full addresses. So you could limit registrations to only .CU domains if you wanted....

avatar carlitorweb carlitorweb - change - 16 Apr 2018
Labels Added: ?
avatar carlitorweb
carlitorweb - comment - 16 Apr 2018

Thank you again @Quy . Also, i added support for TLD.

avatar tonypartridge
tonypartridge - comment - 18 Apr 2018

Actually I support this for the core. Given Joomla’s user base at present this seems like a logical addition to the core.

avatar brianteeman
brianteeman - comment - 18 Apr 2018

there really is no difference to the password limits except now we have some domain limits we already have

avatar infograf768
infograf768 - comment - 21 Apr 2018

Tested here:

  1. Creating user in back-end accepts blacklisted domains.
  2. Modifying account in back-end also
  3. Editing profile in front-end also

I therefore consider this proposal as incomplete.

avatar carlitorweb
carlitorweb - comment - 21 Apr 2018

Thank @infograf768 . What others change can be in this proposal?

avatar carlitorweb carlitorweb - change - 24 Apr 2018
Title
Unique email domain allowed
Whitelist/Blacklist mail domain and TLD allowed
avatar carlitorweb carlitorweb - edited - 24 Apr 2018
avatar carlitorweb carlitorweb - change - 24 Apr 2018
The description was changed
avatar carlitorweb carlitorweb - edited - 24 Apr 2018
avatar carlitorweb carlitorweb - change - 24 Apr 2018
The description was changed
avatar carlitorweb carlitorweb - edited - 24 Apr 2018
avatar infograf768
infograf768 - comment - 30 Apr 2018

To be acceptable, a validation should occur each time the email field is presented to be filled in a form.

avatar dneukirchen
dneukirchen - comment - 30 Apr 2018

First of all: thank you for the contribution! I hate to say that, but at least for me this should not be part of core. Its a 3dp feature, which can easily be implemented using a plugin. We already have enough (confusing) edge case configuration settings.

avatar carlitorweb
carlitorweb - comment - 30 Apr 2018

To be acceptable, a validation should occur each time the email field is presented to be filled in a form.

@infograf768 you mean, validate on the client side too?

First of all: thank you for the contribution! I hate to say that, but at least for me this should not be part of core. Its a 3dp feature, which can easily be implemented using a plugin. We already have enough (confusing) edge case configuration settings.

You welcome @dneukirchen , I glad of contributing to my favorite tool. Hope I can do more. About your opinion, IMHO a lot of things inside Joomla can be as part of a 3dp feature, and not for that, need be out of Joomla. But no problem if this is the reason why this will not be considered to be added to Joomla.

avatar Quy
Quy - comment - 30 Apr 2018

you mean, validate on the client side too?

Here is his previous reply:

Creating user in back-end accepts blacklisted domains.
Modifying account in back-end also
Editing profile in front-end also

In my case, I manage 10 Joomla sites that don't have user registrations so this feature is not applicable.

avatar carlitorweb
carlitorweb - comment - 30 Apr 2018

Thank you @Quy , but I still not understand what mean. Sorry for boring.

In my case, I manage 10 Joomla sites that don't have user registrations so this feature is not applicable.

Well, I decided to make this PR, after found 7 times this request. I read all the comments before about why this featured is not applicable, and is okay if this is a no need. How can I know this decision? Someone on the project come here and close this PR or I need close it?

avatar Quy
Quy - comment - 30 Apr 2018

Editing profile in front-end also

Go to the frontend.
Log in.
Edit your profile.
Change your email address to a blacklisted domain/tld which will be accepted when it should be rejected.

The same applies to the backend.

avatar carlitorweb
carlitorweb - comment - 30 Apr 2018

I got it now @Quy . Thank you, and sorry for no understand before

avatar carlitorweb
carlitorweb - comment - 30 Apr 2018

Added missing validation check when you create/edit a user on the backend. And added missing validation check when you edit a user on the frontend. And sorry again @Quy and @infograf768 for no understand well before when I left this checks out.

avatar carlitorweb carlitorweb - change - 30 Apr 2018
The description was changed
avatar carlitorweb carlitorweb - edited - 30 Apr 2018
avatar infograf768
infograf768 - comment - 2 May 2018

test:
issue solved when editing profile in frontend and editing user in back-end, but not when editing account in backend
link is /administrator/index.php?option=com_admin&task=profile.edit&id=122 (where the id is the user id)
screen shot 2018-05-02 at 09 34 27
The model is /administrator/components/com_admin/models/profile.php

avatar joomla-cms-bot joomla-cms-bot - change - 2 May 2018
Category Administration com_users Language & Strings Front End Administration com_admin com_users Language & Strings Front End
avatar carlitorweb
carlitorweb - comment - 2 May 2018

Thank you again @infograf768 . Is done

avatar carlitorweb carlitorweb - change - 2 May 2018
The description was changed
avatar carlitorweb carlitorweb - edited - 2 May 2018
avatar SharkyKZ
SharkyKZ - comment - 2 May 2018

Even if using two lists, you still need to add an additional option to define default action for domains which aren't on any list. Currently the logic is flawed. Test case:
Add blocked.com to blacklist.
Add allowed.com to whitelist.
Try to register with example.com
The registration will fail even though example.com is not explicitly blacklisted.

Still, I don't think it's correct to have two lists. Unless I'm forgetting some scenario, one list with wildcard support would be better.

avatar carlitorweb
carlitorweb - comment - 2 May 2018

But if you define something inside a whitelist, then you are defining the only patterns that are going to be allowed (is how work a whitelist imho). That is why example.com is not allowed. The condition check as first if something is inside of the blacklist and if it matches yours, if not, then go to the whitelist for doing same, but if the whitelist have some pattern inside, all different email domain/tld will fail, because the site only accept one or several specific patterns

avatar carlitorweb
carlitorweb - comment - 3 May 2018

Done. Thank you @infograf768

avatar infograf768
infograf768 - comment - 4 May 2018

If this PR is accepted, we may think later about adding a check also when entering an address in the mail field for a contact. Not sure if it is necessary.

In the mean while, I think this new feature is nice, simple and should get in.

avatar infograf768 infograf768 - test_item - 4 May 2018 - Tested successfully
avatar SharkyKZ
SharkyKZ - comment - 4 May 2018

But if you define something inside a whitelist, then you are defining the only patterns that are going to be allowed (is how work a whitelist imho).

This is true but the same is true for blacklist. Both lists are of equal importance. So, if there's no default option set by the user, you can't prioritize any of the lists in your code. And because of that, any domain that isn't on any list should be neither blocked nor allowed, which makes no sense. So you do need to add default action.

avatar infograf768
infograf768 - comment - 4 May 2018

@SharkyKZ @carlitorweb
Afterthought: I think whitelist should have priority. If it is empty, then blacklist should take over.
If it is not empty, a check should be done to make sure the same entry does not exist in blacklist, throw an error if there is one or ignore blacklist if none.

avatar carlitorweb
carlitorweb - comment - 4 May 2018

If this PR is accepted, we may think later about adding a check also when entering an address in the mail field for a contact. Not sure if it is necessary.

Good point. I think this field need have the same restriction.

In the mean while, I think this new feature is nice, simple and should get in.

Thank you @infograf768 and for providing a test.

Follow all the opinions of @SharkyKZ, now you can put what restriction you want to use. As @SharkyKZ said, really there is not a scenario where you need use both list. So, one is enough.

select-restriction

I made a commit where you can test this when you create a user inside the backend. If is correct the way, I will make all the change to others place.

avatar carlitorweb carlitorweb - change - 4 May 2018
The description was changed
avatar carlitorweb carlitorweb - edited - 4 May 2018
avatar carlitorweb
carlitorweb - comment - 4 May 2018

I update all the files, for include this new way. Look better now. Thank you @SharkyKZ @infograf768

avatar Quy
Quy - comment - 4 May 2018

The same check/code are in 4 places. Can it be done with a single method?

avatar carlitorweb
carlitorweb - comment - 4 May 2018

For that, I think need an event inside plugin.user but I do not think this check/code it must be there. Not when the option is controlled by the component.

avatar carlitorweb carlitorweb - change - 4 May 2018
The description was changed
avatar carlitorweb carlitorweb - edited - 4 May 2018
avatar carlitorweb carlitorweb - change - 4 May 2018
The description was changed
avatar carlitorweb carlitorweb - edited - 4 May 2018
avatar infograf768
infograf768 - comment - 6 May 2018

The PR is now totally broken. Tested with blacklist domain.

Also: $params are missing when editing frontend profile
Also: I suggest the error lang string to be generic, i.e. added in en-GB.ini (front and backend) as

JGLOBAL_USER_MAIL_DOMAIN_NOT_ALLOWED="This email domain <strong>%s</strong> is not allowed"
avatar infograf768
infograf768 - comment - 6 May 2018

As far as I can see isssue is that $blackListMailDomain as well as $whiteListMailDomain are not defined anymore.

avatar infograf768
infograf768 - comment - 6 May 2018

Tested this OK (Note the single quote for the $optionRestriction value):

			if (!empty(array_filter($listMailDomainTLD)))
			{
				if ($optionRestriction === '2' && !empty(array_intersect($needles, $listMailDomainTLD)))
				{
					$this->setError(JText::sprintf('COM_USERS_REGISTRATION_USER_MAIL_DOMAIN_NOT_ALLOWED_MESSAGE', $userMailDomain[1]));

					return false;
				}
				elseif ($optionRestriction === '1' && empty(array_intersect($needles, $listMailDomainTLD)))
				{
					$this->setError(JText::sprintf('COM_USERS_REGISTRATION_USER_MAIL_DOMAIN_NOT_ALLOWED_MESSAGE', $userMailDomain[1]));

					return false;
				}
			}
avatar carlitorweb
carlitorweb - comment - 7 May 2018

Thank you @infograf768 . Now is okay, and added the global string too.

avatar carlitorweb
carlitorweb - comment - 8 May 2018

Thank you @infograf768 is done.

avatar infograf768
infograf768 - comment - 8 May 2018

I have tested this item successfully on 8882533

Looks OK now.

@SharkyKZ

Please test again.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20164.

avatar infograf768 infograf768 - test_item - 8 May 2018 - Tested successfully
avatar Quy
Quy - comment - 9 May 2018

I can still register with a blacklisted domain.

How about only show these settings when Allow User Registration is enabled?

avatar carlitorweb
carlitorweb - comment - 9 May 2018

Good catch @Quy thank you. I swear I had updated that model with the new changes. Thank you. I test now 10 times, on the administration, and the frontend. Now i not have doubt all work, how need work.

And excellent suggestion, about only show these settings when Allow User Registration is enabled. Is done too.

avatar SharkyKZ
SharkyKZ - comment - 11 May 2018

After considering many options, I think it's best to implement robots.txt-like rules. This would allow for more precise control, including subdomains, wildcard support and user-set priority. And to prevent code duplication, this can be added as an option to EmailRule.

@carlitorweb do you mind if I submit an alternative PR?

avatar carlitorweb
carlitorweb - comment - 11 May 2018

@SharkyKZ no problem.

avatar carlitorweb carlitorweb - change - 14 May 2018
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2018-05-14 12:51:24
Closed_By carlitorweb
avatar carlitorweb carlitorweb - close - 14 May 2018

Add a Comment

Login with GitHub to post a comment