diff --git a/docs/en/authcore.md b/docs/en/authcore.md index 7e941cb..fbe4407 100644 --- a/docs/en/authcore.md +++ b/docs/en/authcore.md @@ -26,6 +26,8 @@ signOutAction="authcore~sign:out" ; action to redirect to when displaying the login page whereas the user is ; already authenticated. Typical action: the action of the home page signInAlreadyAuthAction= +; always/never/enabled/disabled (enabled/disabled : user can override value) +notifyAuthMode= [sessionauth] ; action to redirect to when authentication is needed and the user is not authenticated diff --git a/modules/account/classes/authAccount.listener.php b/modules/account/classes/authAccount.listener.php index 98ae8f9..c5b7d71 100644 --- a/modules/account/classes/authAccount.listener.php +++ b/modules/account/classes/authAccount.listener.php @@ -1,6 +1,7 @@ getUserId(), true); if ($account) { $event->setAccount($account); + $notifier = new AuthenticationNotifier(); + $notifier->successAuth($account); } else { $isAccountCreationAllowed = false; diff --git a/modules/account/controllers/profile.classic.php b/modules/account/controllers/profile.classic.php index 98ca337..18c8d50 100644 --- a/modules/account/controllers/profile.classic.php +++ b/modules/account/controllers/profile.classic.php @@ -6,6 +6,7 @@ use Jelix\Authentication\Account\Manager; use Jelix\Authentication\Account\Account; +use Jelix\Authentication\Account\Notification\AuthenticationNotifier; class profileCtrl extends jController { @@ -27,6 +28,7 @@ function index() { } $form->initFromDao('account~accounts', $formId); + $this->disableNotificationCtrlIfDenied($form); $tpl = new \jTpl(); $tpl->assign('form', $form); @@ -54,6 +56,7 @@ public function modify() } $form->initFromDao('account~accounts', $formId); + $this->disableNotificationCtrlIfDenied($form); $tpl = new jTpl(); $tpl->assign('form', $form); @@ -107,5 +110,13 @@ public function save() return $rep; } + + protected function disableNotificationCtrlIfDenied(jFormsBase $form) { + $notifier = new AuthenticationNotifier(); + + if (!$notifier->canUsersOverwriteNotifConf()) { + $form->getControl('notify_auth_success')->deactivate(); + } + } } diff --git a/modules/account/daos/accounts.dao.xml b/modules/account/daos/accounts.dao.xml index 180c170..2bc40e1 100644 --- a/modules/account/daos/accounts.dao.xml +++ b/modules/account/daos/accounts.dao.xml @@ -25,6 +25,7 @@ 0 new account, invalid account 1 valid account --> + diff --git a/modules/account/forms/profile_modify.form.xml b/modules/account/forms/profile_modify.form.xml index 4a68f57..ece46bc 100644 --- a/modules/account/forms/profile_modify.form.xml +++ b/modules/account/forms/profile_modify.form.xml @@ -16,6 +16,11 @@