/**
  * Teste si un pseudo est présent en base de données
  * @param string $username Le pseudo à tester
  * @return boolean true si présent en base de données, false sinon
  */
 public function usernameExists($username)
 {
     $app = getApp();
     $sql = "SELECT " . $app->getConfig('security_username_property') . " FROM " . $app->getConfig('security_user_table') . " WHERE " . $app->getConfig('security_username_property') . " = :username LIMIT 1";
     $dbh = ConnectionManager::getDbh();
     $sth = $dbh->prepare($sql);
     $sth->bindValue(":username", $username);
     if ($sth->execute()) {
         $foundUser = $sth->fetch();
         if ($foundUser) {
             return true;
         }
     }
     return false;
 }
예제 #2
0
파일: UserManager.php 프로젝트: nadiadev/W
 /**
  * Récupère un utilisateur en fonction de son email ou de son pseudo
  * @param string $usernameOrEmail Le pseudo ou l'email d'un utilisateur
  * @return mixed L'utilisateur, ou false si non trouvé
  */
 public function getUserByUsernameOrEmail($usernameOrEmail)
 {
     $app = getApp();
     $sql = "SELECT * FROM " . $app->getConfig('security_user_table') . " WHERE " . $app->getConfig('security_username_property') . " = :username OR " . $app->getConfig('security_email_property') . " = :email LIMIT 1";
     $dbh = ConnectionManager::getDbh();
     $sth = $dbh->prepare($sql);
     $sth->bindValue(":username", $usernameOrEmail);
     $sth->bindValue(":email", $usernameOrEmail);
     if ($sth->execute()) {
         $foundUser = $sth->fetch();
         if ($foundUser) {
             return $foundUser;
         }
     }
     return false;
 }
예제 #3
0
 /**
  * Constructeur
  */
 public function __construct()
 {
     $this->setTableFromClassName();
     $this->dbh = ConnectionManager::getDbh();
 }