diff --git a/core/module/user/user.php b/core/module/user/user.php
index 98564848..01c4eef0 100644
--- a/core/module/user/user.php
+++ b/core/module/user/user.php
@@ -1176,7 +1176,14 @@ class user extends common
// Vérifier la clé saisie
$targetKey = $this->getData(['user', $this->getUser('id'), 'authKey']);
$inputKey = $this->getInput('userAuthKey', helper::FILTER_INT);
- if ($targetKey === $inputKey) {
+ // Supprime la clé stockée et ltemps limite
+ $this->deleteData(['user', $this->getUser('id'), 'authKey']);
+ // Réinitialiser le compteur de temps
+ $this->setData(['user', $this->getUser('id'), 'connectTimeout', 0]);
+ if (
+ $targetKey === $inputKey &&
+ $this->getData(['user', $this->getUser('id'), 'connectTimeout']) + 3600 >= time()
+ ) {
$pageId = $this->getUrl(2);
// La fiche de l'utilisateur contient la clé d'authentification
$this->setData(['user', $this->getUser('id'), 'authKey', $this->getInput('ZWII_AUTH_KEY')]);
@@ -1212,23 +1219,32 @@ class user extends common
* Envoi d'un email contenant une clé
* Stockage de la clé dans le compte de l'utilisateur
*/
- $sent = $this->sendMail(
- $this->getUser('mail'),
- 'Tentative de connexion à votre',
- //'Bonjour ' . $item['prenom'] . ' ' . $item['nom'] . ',
' .
- '
Clé de validation à saisir dans le formulaire :
' .
- ''.$this->getData(['user', $this->getUser('id'), 'authKey']).'
',
- null,
- $this->getData(['config', 'smtp', 'from'])
- );
+ // La clé est envoyée une seule fois
+ $sent = false;
+ if (
+ $this->getData(['user', $this->getUser('id'), 'authKey'])
+ && $this->getData(['user', $this->getUser('id'), 'connectTimeout']) === 0
+ ) {
+ $sent = $this->sendMail(
+ $this->getUser('mail'),
+ 'Tentative de connexion à votre',
+ //'Bonjour ' . $item['prenom'] . ' ' . $item['nom'] . ',
' .
+ 'Clé de validation à saisir dans le formulaire :
' .
+ '' . $this->getData(['user', $this->getUser('id'), 'authKey']) . '
',
+ null,
+ $this->getData(['config', 'smtp', 'from'])
+ );
+ // Stocker l'envoi de l'email
+ $this->setData(['user', $this->getUser('id'), 'connectTimeout', time()]);
+ }
+
// Message envoyé sinon la connexion est réalisée pour ne pas bloquer.
- if ($sent === true) {
- // Valider l'authentification en stockant la clé
- // Rediriger vers la page ou l'accueil
+ if ($sent === false) {
+
}
// Valeurs en sortie
$this->addOutput([
- 'title' => helper::translate('Authentification'),
+ 'title' => helper::translate('Double authentification'),
'view' => 'auth',
'display' => self::DISPLAY_LAYOUT_LIGHT,
]);
diff --git a/core/module/user/view/auth/auth.css b/core/module/user/view/auth/auth.css
index 7fd86067..e2179322 100644
--- a/core/module/user/view/auth/auth.css
+++ b/core/module/user/view/auth/auth.css
@@ -18,14 +18,6 @@
* admin.css
*/
-
-#passwordLabel, #passwordIcon {
- display: inline-flex;
-}
-#passwordIcon {
- float: right;
-}
-
@media screen and (max-width: 768px) {
#buttonsContainer {
display: grid;
@@ -36,4 +28,9 @@
#backContainer{
order: 2;
}
+}
+
+#userAuthKey {
+ text-align: center;
+ font-size: 1.3rem;
}
\ No newline at end of file
diff --git a/core/module/user/view/auth/auth.php b/core/module/user/view/auth/auth.php
index 04a965d3..ca948b6f 100644
--- a/core/module/user/view/auth/auth.php
+++ b/core/module/user/view/auth/auth.php
@@ -1,8 +1,8 @@
-
+
helper::translate('Clé')
+ 'label' => helper::translate('Clé reçue par couriel')
]); ?>
@@ -15,7 +15,7 @@
helper::translate('Connexion'),
+ 'value' => helper::translate('Authentification'),
'ico' => ''
]); ?>