Skip to content

Commit

Permalink
Put new option adn code for frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
carlitorweb committed May 4, 2018
1 parent 9b773a1 commit 20bfc21
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 27 deletions.
39 changes: 25 additions & 14 deletions components/com_users/models/profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,23 +305,34 @@ public function save($data)
$data['password'] = $data['password1'];

// Check if the user mail domain or TLD is disallowed
$params = $this->getState('params');
$whiteListMailDomain = explode("\r\n", $params->get('whiteListMailDomain'));
$blackListMailDomain = explode("\r\n", $params->get('blackListMailDomain'));
$userMailDomain = explode('@', $data['email']);
$getTLD = explode('.', $userMailDomain[1]);
$userMailTLD = array_pop($getTLD);
$needles = array(
'userMailDomain' => $userMailDomain[1],
'userMailTLD' => $userMailTLD,
);
$optionRestriction = $params->get('domainTLDRestriction');

if ((!empty(array_filter($blackListMailDomain)) && !empty(array_intersect($needles, $blackListMailDomain)))
|| (!empty(array_filter($whiteListMailDomain)) && empty(array_intersect($needles, $whiteListMailDomain))))
if ($optionRestriction !== '0')
{
$this->setError(JText::sprintf('COM_USERS_REGISTRATION_USER_MAIL_DOMAIN_NOT_ALLOWED_MESSAGE', $userMailDomain[1]));
$listMailDomainTLD = explode("\r\n", $params->get('listMailDomainTLD'));
$userMailDomain = explode('@', $data['email']);
$getTLD = explode('.', $userMailDomain[1]);
$userMailTLD = array_pop($getTLD);
$needles = array(
'userMailDomain' => $userMailDomain[1],
'userMailTLD' => $userMailTLD,
);

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

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

return false;
}
}
}

// Unset the username if it should not be overwritten
Expand Down
38 changes: 25 additions & 13 deletions components/com_users/models/registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -424,22 +424,34 @@ public function register($temp)
$sendpassword = $params->get('sendpassword', 1);

// Check if the user mail domain or TLD is disallowed
$whiteListMailDomain = explode("\r\n", $params->get('whiteListMailDomain'));
$blackListMailDomain = explode("\r\n", $params->get('blackListMailDomain'));
$userMailDomain = explode('@', $data['email']);
$getTLD = explode('.', $userMailDomain[1]);
$userMailTLD = array_pop($getTLD);
$needles = array(
'userMailDomain' => $userMailDomain[1],
'userMailTLD' => $userMailTLD,
);
$optionRestriction = $params->get('domainTLDRestriction');

if ((!empty(array_filter($blackListMailDomain)) && !empty(array_intersect($needles, $blackListMailDomain)))
|| (!empty(array_filter($whiteListMailDomain)) && empty(array_intersect($needles, $whiteListMailDomain))))
if ($optionRestriction !== '0')
{
$this->setError(JText::sprintf('COM_USERS_REGISTRATION_USER_MAIL_DOMAIN_NOT_ALLOWED_MESSAGE', $userMailDomain[1]));
$listMailDomainTLD = explode("\r\n", $params->get('listMailDomainTLD'));
$userMailDomain = explode('@', $data['email']);
$getTLD = explode('.', $userMailDomain[1]);
$userMailTLD = array_pop($getTLD);
$needles = array(
'userMailDomain' => $userMailDomain[1],
'userMailTLD' => $userMailTLD,
);

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

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

return false;
}
}
}

// Check if the user needs to activate their account.
Expand Down

0 comments on commit 20bfc21

Please sign in to comment.