コード例 #1
0
ファイル: DbInstaller.php プロジェクト: kisorbiswal/Creamy
 private function setupUsersTable($initialUser, $initialPass, $initialEmail)
 {
     // users data table.
     $fields = array("name" => "VARCHAR(255) NOT NULL", "password_hash" => "VARCHAR(255) NOT NULL", "phone" => "VARCHAR(255) DEFAULT NULL", "email" => "VARCHAR(255) DEFAULT NULL", "avatar" => "VARCHAR(255) DEFAULT NULL", "creation_date" => "DATETIME NOT NULL", "role" => "INT(4) NOT NULL", "status" => "INT(1) NOT NULL");
     if (!$this->dbConnector->createTable(CRM_USERS_TABLE_NAME, $fields, ["name", "email"])) {
         $this->error = "Creamy install: Failed to create table " . CRM_USERS_TABLE_NAME . ".";
         return false;
     }
     // create main admin users.
     $password_hash = \creamy\PassHash::hash($initialPass);
     $data = array("name" => $initialUser, "password_hash" => $password_hash, "email" => $initialEmail, "avatar" => CRM_DEFAULTS_USER_AVATAR, "creation_date" => "now()", "role" => CRM_DEFAULTS_USER_ROLE_ADMIN, "status" => CRM_DEFAULTS_USER_ENABLED);
     if (!$this->dbConnector->insert(CRM_USERS_TABLE_NAME, $data)) {
         $this->error = "Creamy install: Failed to insert the initial admin user.";
         return false;
     }
     return true;
 }
コード例 #2
0
ファイル: DbHandler.php プロジェクト: kisorbiswal/Creamy
 /** 
  * Changes the password of a user identified by an email. The user must have a valid email in the database.
  * @param $email String the email of the user.
  * @param $password the new password for the user.
  */
 public function changePasswordForUserIdentifiedByEmail($email, $password)
 {
     if ($this->userExistsIdentifiedByEmail($email)) {
         // Generating password hash
         $password_hash = \creamy\PassHash::hash($password);
         $this->dbConnector->where("email", $email);
         $data = array("password_hash" => $password_hash);
         return $this->dbConnector->update(CRM_USERS_TABLE_NAME, $data);
     }
     return false;
 }