/** * Validates the password. * This method serves as the inline validation for password. * * @param string $attribute the attribute currently being validated * @param array $params the additional name-value pairs given in the rule */ public function validatePassword($attribute, $params) { $user = \backend\models\Employee::findIdentity(Yii::$app->getUser()->getId()); if (!$user->validatePassword($this->old_password)) { $this->addError($attribute, Yii::t('app', 'Old password is incorrect')); } }
public function actionIndex($id = null) { Url::remember(); if ($id == null) { $myself = true; $model = Yii::$app->getUser()->getIdentity(); } else { $myself = false; $model = Employee::findIdentity($id); } return $this->render('index', ['model' => $model]); }
public function __construct($userId, $config = array()) { $this->user = Employee::findIdentity($userId); if ($this->user === null) { throw new \yii\web\NotFoundHttpException(Yii::t("app", "Not found employee with specify id")); } $this->allRoles['none'] = Yii::t('app', 'Not yet set role'); foreach (Yii::$app->getAuthManager()->getRoles() as $role) { $this->allRoles[$role->name] = ucfirst($role->name); } $roles = Yii::$app->getAuthManager()->getRolesByUser($userId); $this->roleName = count($roles) > 0 ? array_values($roles)[0]->name : 'none'; parent::__construct($config); }
<?php echo $model->attributeLabels()['email']; ?> </li> <li class="list-group-item"> <span class="pull-right"> <?php echo $model->created_by == 0 ? "Console App" : Employee::findIdentity($model->created_by)->username; ?> </span> <?php echo $model->attributeLabels()['created_by']; ?> </li> <li class="list-group-item"> <span class="pull-right"> <?php echo $model->created_by == 0 ? "Console App" : Employee::findIdentity($model->created_by)->username; ?> </span> <?php echo $model->attributeLabels()['updated_by']; ?> </li> <li class="list-group-item"> <span class="pull-right"> <?php echo date("d/m/Y h:i:s", $model->created_at); ?> </span> <?php echo $model->attributeLabels()['created_at']; ?> </li>