Skip to content

Commit

Permalink
use dispatch in rule
Browse files Browse the repository at this point in the history
  • Loading branch information
ron4mac committed Feb 28, 2021
1 parent 613ffc9 commit 3eafa5d
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion language/en-GB/en-GB.plg_user_regauth.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; @package Registration Authorization User Plugin
; @copyright (C) 2016 RJCreations. All rights reserved.
; @copyright (C) 2016-2021 RJCreations. All rights reserved.
; @license GNU General Public License version 3 or later; see LICENSE.txt
; Note : All ini files need to be saved as UTF-8

Expand Down
2 changes: 1 addition & 1 deletion language/en-GB/en-GB.plg_user_regauth.sys.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; @package Registration Authorization User Plugin
; @copyright (C) 2016 RJCreations. All rights reserved.
; @copyright (C) 2016-2021 RJCreations. All rights reserved.
; @license GNU General Public License version 3 or later; see LICENSE.txt
; Note : All ini files need to be saved as UTF-8

Expand Down
2 changes: 1 addition & 1 deletion language/en-US/en-US.plg_user_regauth.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; @package Registration Authorization User Plugin
; @copyright (C) 2016 RJCreations. All rights reserved.
; @copyright (C) 2016-2021 RJCreations. All rights reserved.
; @license GNU General Public License version 3 or later; see LICENSE.txt
; Note : All ini files need to be saved as UTF-8

Expand Down
2 changes: 1 addition & 1 deletion language/en-US/en-US.plg_user_regauth.sys.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; @package Registration Authorization User Plugin
; @copyright (C) 2016 RJCreations. All rights reserved.
; @copyright (C) 2016-2021 RJCreations. All rights reserved.
; @license GNU General Public License version 3 or later; see LICENSE.txt
; Note : All ini files need to be saved as UTF-8

Expand Down
7 changes: 7 additions & 0 deletions regauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ public function onUserBeforeDataValidation ($form, &$data)
}


// triggered by the registration form authcode validation rule
public function onPlgRegAuthValidate ($authcode)
{
return array_key_exists($authcode, $this->codes);
}


const METHOD = 'aes-128-ctr';

private function encrypt ($message, $key)
Expand Down
12 changes: 3 additions & 9 deletions rules/authcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\Registry\Registry;

class JFormRuleAuthcode extends JFormRule
Expand All @@ -15,16 +16,9 @@ public function test(SimpleXMLElement $element, $value, $group = null, Registry
$authcode = trim($value);
if (!$authcode) return false;

$params = new Registry(JPluginHelper::getPlugin('user','regauth')->params);
$codes = [];
for ($i=1; $i<7; $i++) {
$code = trim($params->get('authcode'.$i, ''));
if ($code) {
$codes[] = $code;
}
}
$result = Factory::getApplication()->triggerEvent('onPlgRegAuthValidate', [$authcode]);
if (is_array($result)) return $result[0];

if (in_array($authcode, $codes)) return true;
return false;
}

Expand Down

0 comments on commit 3eafa5d

Please sign in to comment.