Bladeren bron

[Administration] Utilisateurs > modifier : pouvoir définir un mot de passe manuellement

feature/rotating_product
Guillaume Bourgeois 6 maanden geleden
bovenliggende
commit
9a387b3094
2 gewijzigde bestanden met toevoegingen van 25 en 0 verwijderingen
  1. +9
    -0
      backend/controllers/UserController.php
  2. +16
    -0
      backend/views/user/_form.php

+ 9
- 0
backend/controllers/UserController.php Bestand weergeven

@@ -235,6 +235,15 @@ class UserController extends BackendController
$userBelongToProducer->trust_alert_comment = $model->trust_alert_comment;
$userBelongToProducer->save();

// Mot de passe
if($this->getUserModule()->getAuthorizationChecker()->isGrantedAsAdministrator($this->getUserCurrent())
&& $model->password_new
&& strlen($model->password_new)) {

$this->getUserModule()->getBuilder()->initPassword($model, $model->password_new);
$model->save();
}

$this->setFlash('success', 'Utilisateur <strong>' . Html::encode($userModule->getUsername($model)) . '</strong> modifié.');
return $this->redirect(['view', 'id' => $model->id]);
}

+ 16
- 0
backend/views/user/_form.php Bestand weergeven

@@ -36,6 +36,7 @@
* termes.
*/

use common\helpers\GlobalParam;
use domain\Distribution\Distribution\DistributionModule;
use domain\Distribution\Distribution\ExportManager;
use domain\Producer\Producer\ProducerModule;
@@ -45,6 +46,7 @@ use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\ActiveForm;

$userCurrent = GlobalParam::getCurrentUser();
$userModule = UserModule::getInstance();
$producerModule = ProducerModule::getInstance();
$distributionModule = DistributionModule::getInstance();
@@ -86,6 +88,20 @@ $distributionModule = DistributionModule::getInstance();
</div>
</div>

<?php if($userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent)): ?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<i class="fa fa-lock"></i>
Mot de passe
</h3>
</div>
<div class="panel-body">
<?= $form->field($model, 'password_new')->passwordInput() ?>
</div>
</div>
<?php endif; ?>

<?php if($pointsSaleArray && count($pointsSaleArray) > 0): ?>
<div class="panel panel-default panel-point-sales">
<div class="panel-heading">

Laden…
Annuleren
Opslaan