Beispiel #1
0
 public function changePassword($username, $oldPassword, $newPassword)
 {
     //Encrypt the passwords
     $oldPassword = Operations::encryptPassword($username, $oldPassword);
     $newPassword = Operations::encryptPassword($username, $newPassword);
     //Grab the account with the given username and password
     $account = $this->getAccount(array($username, $oldPassword), "user_pass");
     //If not null, then the details existed, which means we can change the password
     if ($account != null) {
         $this->dbConnect();
         $sql = "UPDATE users SET password = ? WHERE username = ?";
         $stmt = $this->con->prepare($sql);
         $stmt->bindParam(1, $newPassword);
         $stmt->bindParam(2, $username);
         $stmt->execute();
         $this->dbDisconnect();
         return "password_changed";
     } else {
         return "no_old_password_match";
     }
 }