diff --git a/core/module/user/user.php b/core/module/user/user.php index 7c2de47d..96e64040 100644 --- a/core/module/user/user.php +++ b/core/module/user/user.php @@ -266,25 +266,37 @@ class user extends common $this->isPost() ) { // Double vérification pour le mot de passe - $newPassword = $this->getData(['user', $this->getUrl(2), 'password']); - if ($this->getInput('userEditNewPassword')) { - // L'ancien mot de passe est correct - if (password_verify(html_entity_decode($this->getInput('userEditOldPassword')), $this->getData(['user', $this->getUrl(2), 'password']))) { - // La confirmation correspond au mot de passe - if ($this->getInput('userEditNewPassword') === $this->getInput('userEditConfirmPassword')) { - $newPassword = $this->getInput('userEditNewPassword', helper::FILTER_PASSWORD, true); - // Déconnexion de l'utilisateur si il change le mot de passe de son propre compte - if ($this->getUser('id') === $this->getUrl(2)) { - helper::deleteCookie('ZWII_USER_ID'); - helper::deleteCookie('ZWII_USER_PASSWORD'); + if ($this->getUser('group') < self::GROUP_ADMIN) { + $newPassword = $this->getData(['user', $this->getUrl(2), 'password']); + if ($this->getInput('userEditNewPassword')) { + // L'ancien mot de passe est correct + if (password_verify(html_entity_decode($this->getInput('userEditOldPassword')), $this->getData(['user', $this->getUrl(2), 'password']))) { + // La confirmation correspond au mot de passe + if ($this->getInput('userEditNewPassword') === $this->getInput('userEditConfirmPassword')) { + $newPassword = $this->getInput('userEditNewPassword', helper::FILTER_PASSWORD, true); + // Déconnexion de l'utilisateur si il change le mot de passe de son propre compte + if ($this->getUser('id') === $this->getUrl(2)) { + helper::deleteCookie('ZWII_USER_ID'); + helper::deleteCookie('ZWII_USER_PASSWORD'); + } + } else { + self::$inputNotices['userEditConfirmPassword'] = helper::translate('Incorrect'); } } else { - self::$inputNotices['userEditConfirmPassword'] = helper::translate('Incorrect'); + self::$inputNotices['userEditOldPassword'] = helper::translate('Incorrect'); + } + } + } else { + if ($this->getInput('userEditNewPassword') === $this->getInput('userEditConfirmPassword')) { + $newPassword = $this->getInput('userEditNewPassword', helper::FILTER_PASSWORD, true); + // Déconnexion de l'utilisateur si il change le mot de passe de son propre compte + if ($this->getUser('id') === $this->getUrl(2)) { + helper::deleteCookie('ZWII_USER_ID'); + helper::deleteCookie('ZWII_USER_PASSWORD'); } - } else { - self::$inputNotices['userEditOldPassword'] = helper::translate('Incorrect'); } } + // Modification du groupe if ( $this->getUser('group') === self::GROUP_ADMIN diff --git a/core/module/user/view/edit/edit.php b/core/module/user/view/edit/edit.php index 26c03c6a..7e84097e 100644 --- a/core/module/user/view/edit/edit.php +++ b/core/module/user/view/edit/edit.php @@ -81,11 +81,15 @@ 'readonly' => true, 'value' => $this->getUrl(2) ]); ?> - 'new-password', - // remplace 'off' pour éviter le pré remplissage auto - 'label' => 'Ancien mot de passe' - ]); ?> + getUser('group') < self::GROUP_ADMIN): ?> + 'new-password', + // remplace 'off' pour éviter le pré remplissage auto + 'label' => 'Ancien mot de passe', + ]); ?> + 'off', 'label' => 'Nouveau mot de passe'