backend change password

This commit is contained in:
akosse
2020-01-23 13:16:54 +03:00
parent 8322d58066
commit dfbcdbae6e
4 changed files with 88 additions and 1 deletions

View File

@ -65,6 +65,28 @@ class UserCardController extends Controller
]);
}
public function actionPassword($id)
{
$user_card = UserCard::findOne($id);
$model = User::findOne(['id' => $user_card->id_user]);
return $this->render('password', [
'model' => $model,
]);
}
public function actionAjax() {
if(Yii::$app->request->isAjax) {
$id = $_POST['id'];
$password = $_POST['password'];
$user_card = UserCard::findOne($id);
$user = User::findOne(['id' => $user_card->id_user]);
$user->password = $password;
$user->save();
}
}
/**
* Displays a single UserCard model.
* @param integer $id

View File

@ -0,0 +1,22 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
?>
<?php $form = ActiveForm::begin([
'id' => 'password-form',
'enableClientValidation' => true,
'enableAjaxValidation' => false,
'method' => 'post',
]); ?>
<h4>Введите новый пароль</h4>
<?= Html::input('text', 'password', '', ['class' => 'form-control custom-input']) ?>
<br>
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
<?php echo '&nbsp' . Html::button('Сгенерировать', ['class' => 'btn btn-success generate']); ?>
<?php ActiveForm::end(); ?>

View File

@ -12,6 +12,9 @@ $this->params['breadcrumbs'][] = 'Редактировать';
?>
<div class="user-card-update">
<?php echo Html::a('Изменить пароль', ['password', 'id' => $model->id], ['class' => 'btn btn-success']);
?>
<?= $this->render('_form', [
'model' => $model,
]) ?>