Esempio n. 1
0
 public function login($login, $password)
 {
     $db = $this->serviceManager->get('PDO');
     $userDao = $this->serviceManager->getDao('UserDao');
     $user = $userDao->getByLogin($login);
     if ($this->isLoggedIn($user->getId())) {
         return false;
     }
     if (Authorization::validatePassword($password, $user->getPasswordHash())) {
         if (!$user->getStatus()) {
             return false;
         } else {
             $this->user = $user;
             $timeout = time() + $this->loginTimeOut;
             $_SESSION['loginTimeOut'] = $timeout;
             $STH = $db->prepare("UPDATE " . DBConfig::table(DBConfig::AUTHORIZATION) . " SET id_u=:id_u, timeout=:to, url=:url WHERE id_auth=:id_a LIMIT 1;");
             $STH->bindValue(':id_a', $this->authId, PDO::PARAM_INT);
             $STH->bindValue(':id_u', $this->user->getId(), PDO::PARAM_INT);
             $STH->bindValue(':to', $timeout, PDO::PARAM_INT);
             $STH->bindValue(':url', $_SERVER['REQUEST_URI'], PDO::PARAM_STR);
             return $STH->execute() ? true : false;
         }
     } else {
         return false;
     }
 }
Esempio n. 2
0
 public function getUserGroups(RoleInterface $user)
 {
     $stmt = $this->getConnection()->prepare('SELECT id_g FROM test_group_members WHERE id_u=:id;');
     $stmt->bindValue(':id', $user->getId());
     $result = $this->customQuery($stmt);
     $ret = array();
     foreach ($result as $r) {
         $ret[] = $this->find($r['id_g']);
     }
     return $ret;
 }
Esempio n. 3
0
 public function removeGroup(RoleInterface $user, Group $group)
 {
     $stmt = $this->getConnection()->prepare('DELETE FROM test_group_members WHERE id_u=:u && id_g=:g');
     $stmt->bindValue(':u', $user->getId());
     $stmt->bindValue(':g', $group->getId());
     return $this->customQuery($stmt);
 }