Skip to content

Commit

Permalink
Validation editing account in backend
Browse files Browse the repository at this point in the history
  • Loading branch information
carlitorweb committed May 2, 2018
1 parent 6552e5a commit 62e2131
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions administrator/components/com_admin/models/profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,26 @@ public function save($data)
{
$user = JFactory::getUser();

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

if ((!empty(array_filter($blackListMailDomain)) && !empty(array_intersect($needles, $blackListMailDomain)))
|| (!empty(array_filter($whiteListMailDomain)) && empty(array_intersect($needles, $whiteListMailDomain))))
{
$this->setError(JText::sprintf('COM_USERS_MSG_USER_MAIL_DOMAIN_NOT_ALLOWED', $userMailDomain[1]));

return false;
}

unset($data['id']);
unset($data['groups']);
unset($data['sendEmail']);
Expand Down

0 comments on commit 62e2131

Please sign in to comment.