Browse Source

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

feature/rotating_product
Guillaume Bourgeois 6 months ago
parent
commit
9a387b3094
2 changed files with 25 additions and 0 deletions
  1. +9
    -0
      backend/controllers/UserController.php
  2. +16
    -0
      backend/views/user/_form.php

+ 9
- 0
backend/controllers/UserController.php View File

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

+ 16
- 0
backend/views/user/_form.php View File

* termes. * termes.
*/ */


use common\helpers\GlobalParam;
use domain\Distribution\Distribution\DistributionModule; use domain\Distribution\Distribution\DistributionModule;
use domain\Distribution\Distribution\ExportManager; use domain\Distribution\Distribution\ExportManager;
use domain\Producer\Producer\ProducerModule; use domain\Producer\Producer\ProducerModule;
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\ActiveForm; use yii\widgets\ActiveForm;


$userCurrent = GlobalParam::getCurrentUser();
$userModule = UserModule::getInstance(); $userModule = UserModule::getInstance();
$producerModule = ProducerModule::getInstance(); $producerModule = ProducerModule::getInstance();
$distributionModule = DistributionModule::getInstance(); $distributionModule = DistributionModule::getInstance();
</div> </div>
</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): ?> <?php if($pointsSaleArray && count($pointsSaleArray) > 0): ?>
<div class="panel panel-default panel-point-sales"> <div class="panel panel-default panel-point-sales">
<div class="panel-heading"> <div class="panel-heading">

Loading…
Cancel
Save