diff --git a/src/Controller/Component/UsersAuthComponent.php b/src/Controller/Component/UsersAuthComponent.php index f45ef42a4..d5d218ea6 100644 --- a/src/Controller/Component/UsersAuthComponent.php +++ b/src/Controller/Component/UsersAuthComponent.php @@ -30,6 +30,7 @@ class UsersAuthComponent extends Component const EVENT_AFTER_COOKIE_LOGIN = 'Users.Component.UsersAuth.afterCookieLogin'; const EVENT_BEFORE_REGISTER = 'Users.Component.UsersAuth.beforeRegister'; const EVENT_AFTER_REGISTER = 'Users.Component.UsersAuth.afterRegister'; + const EVENT_AFTER_REGISTER_CONFIRM = 'Users.Component.UsersAuth.afterRegister.confirm'; const EVENT_BEFORE_LOGOUT = 'Users.Component.UsersAuth.beforeLogout'; const EVENT_AFTER_LOGOUT = 'Users.Component.UsersAuth.afterLogout'; const EVENT_BEFORE_SOCIAL_LOGIN_USER_CREATE = 'Users.Component.UsersAuth.beforeSocialLoginUserCreate'; diff --git a/src/Controller/Traits/ProfileTrait.php b/src/Controller/Traits/ProfileTrait.php index db61724d3..f7c18a443 100644 --- a/src/Controller/Traits/ProfileTrait.php +++ b/src/Controller/Traits/ProfileTrait.php @@ -40,8 +40,8 @@ public function profile($id = null) $appContain = (array)Configure::read('Auth.authenticate.' . AuthComponent::ALL . '.contain'); $socialContain = Configure::read('Users.Social.login') ? ['SocialAccounts']: []; $user = $this->getUsersTable()->get($id, [ - 'contain' => array_merge((array)$appContain, (array)$socialContain) - ]); + 'contain' => array_merge((array)$appContain, (array)$socialContain) + ]); $this->set('avatarPlaceholder', Configure::read('Users.Avatar.placeholder')); if ($user->id === $loggedUserId) { $isCurrentUser = true; diff --git a/src/Controller/Traits/UserValidationTrait.php b/src/Controller/Traits/UserValidationTrait.php index 2229c7abb..53781087c 100644 --- a/src/Controller/Traits/UserValidationTrait.php +++ b/src/Controller/Traits/UserValidationTrait.php @@ -11,6 +11,8 @@ namespace CakeDC\Users\Controller\Traits; +use CakeDC\Users\Controller\Component\UsersAuthComponent; +use Cake\Event\Event; use CakeDC\Users\Exception\TokenExpiredException; use CakeDC\Users\Exception\UserAlreadyActiveException; use CakeDC\Users\Exception\UserNotFoundException; @@ -39,7 +41,14 @@ public function validate($type = null, $token = null) case 'email': try { $result = $this->getUsersTable()->validate($token, 'activateUser'); + if ($result) { + $event = $this->dispatchEvent(UsersAuthComponent::EVENT_AFTER_REGISTER_CONFIRM, [ + 'user' => $result + ]); + if ($event->result instanceof Response) { + return $this->redirect(['action' => 'login']); + } $this->Flash->success(__d('CakeDC/Users', 'User account validated successfully')); } else { $this->Flash->error(__d('CakeDC/Users', 'User account could not be validated')); diff --git a/src/View/Helper/UserHelper.php b/src/View/Helper/UserHelper.php index c1f4cb7b7..e59f85b5a 100644 --- a/src/View/Helper/UserHelper.php +++ b/src/View/Helper/UserHelper.php @@ -146,7 +146,10 @@ public function addReCaptcha() return $this->Html->tag('div', '', [ 'class' => 'g-recaptcha', - 'data-sitekey' => Configure::read('Users.reCaptcha.key') + 'data-sitekey' => Configure::read('Users.reCaptcha.key'), + 'data-theme' => Configure::read('Users.reCaptcha.theme') ?: 'light', + 'data-size' => Configure::read('Users.reCaptcha.size') ?: 'normal', + 'data-tabindex' => Configure::read('Users.reCaptcha.tabindex') ?: '3', ]); }