Exemplo n.º 1
0
 public function getPermissionsByUser($user = null)
 {
     if ($user === LuLu::getIdentity()->username) {
         $role = LuLu::getIdentity()->role;
     } else {
         $user = User::findOne(['username' => $user]);
         $role = $user->role;
     }
     return $this->getPermissionsByRole($role);
     //        //for assignmentTable
     //         $query = new Query();
     //         $query->select([
     //             'p.id',
     //             'p.category',
     //             'p.name',
     //             'p.description',
     //             'p.form',
     //             'p.default_value',
     //             'p.rule',
     //             'p.sort_num',
     //             'r.role',
     //             'r.value'
     //         ]);
     //         $query->from([
     //             'p' => $this->permissionTable,
     //             'r' => $this->relationTable,
     //             'a' => $this->assignmentTable
     //         ]);
     //         $query->where('p.id=r.permission and r.role=a.role');
     //         $query->andWhere([
     //             'a.user' => $user
     //         ]);
     //         $rows = $query->all();
     //         return $this->convertPermissionValue($rows);
 }
Exemplo n.º 2
0
 public function getRolesByUser($username)
 {
     if ($username === LuLu::getIdentity()->username) {
         $role = LuLu::getIdentity()->role;
     } else {
         $user = User::findOne(['username' => $username]);
         $role = $user->role;
     }
     return $role;
     //         $query = new Query();
     //         $query->select([
     //             'r.id',
     //             'r.category',
     //             'r.name',
     //             'r.description',
     //             'r.is_system',
     //             'r.sort_num'
     //         ]);
     //         $query->from([
     //             'r' => $this->roleTable,
     //             'a' => $this->assignmentTable
     //         ]);
     //         $query->where('r.id=a.role');
     //         $query->andWhere([
     //             'a.user' => $username
     //         ]);
     //         $rows = $query->indexBy('id')->all();
     //         return $rows;
 }
Exemplo n.º 3
0
 /**
  * Finds the User model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return User the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = User::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 4
0
 public function login()
 {
     if (!$this->validate()) {
         return false;
     }
     $user = User::findOne(['username' => $this->username]);
     if ($user !== null) {
         if ($this->validatePassword($this->password, $user->password_hash)) {
             \Yii::$app->user->login($user, 50000);
             return true;
         }
         return false;
     } else {
         return false;
     }
 }