Exemplo n.º 1
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         if ($insert) {
             $this->id = \app\components\mytools::getCurrentID2();
             $this->auth_key = \Yii::$app->security->generateRandomKey();
             $this->access_token = \Yii::$app->security->generateRandomString();
         }
         $this->password = \app\components\mytools::getMySQLPassword($this->password);
         $this->userlog = Yii::$app->user->id;
         $this->datetimelog = \app\components\mytools::getDateTime();
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 2
0
</h1>

    <p>
        <?php 
echo Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a('Delete', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]);
?>
    </p>
	<?php 
echo \app\components\mytools::getFullnameByUser($model->id);
?>
    
    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'username', 'fullname', 'access_token', 'auth_key', 'active', ['attribute' => 'userlog', 'value' => \app\components\mytools::getFullnameByUser($model->id)], 'datetimelog']]);
?>
    
    <h2>Roles / Peran</h2>
    <p>
    <?php 
echo Html::a('Add Role', ['addrole', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
    </p>    
    <?php 
//$roles = Yii::$app->authManager->getRolesByUser($model->id);
$roles = (new yii\db\Query())->select('')->from('auth_assignment a')->join('INNER JOIN', 'auth_item b', 'b.name = a.item_name')->where(['a.user_id' => $model->id])->All(Yii::$app->authdb);
$rolesProvider = new \yii\data\ArrayDataProvider(['allModels' => $roles]);
echo GridView::widget(['dataProvider' => $rolesProvider, 'columns' => ['name', 'description', ['class' => yii\grid\ActionColumn::className(), 'template' => '{delete}', 'urlCreator' => function ($action, $model, $key, $index) {
    return Yii::$app->urlManager->createUrl(['rbac/authassignment/delete2', 'item_name' => $model['name'], 'user_id' => $model['user_id']]);
}]]]);
Exemplo n.º 3
0
 /**
  * Validates password
  *
  * @param  string  $password password to validate
  * @return boolean if password provided is valid for current user
  */
 public function validatePassword($password)
 {
     $encpassword = \app\components\mytools::getMySQLPassword($password);
     return $this->password === $encpassword;
 }