Skip to content

Commit

Permalink
Return the more specific InvalidCredentials error
Browse files Browse the repository at this point in the history
  • Loading branch information
mihai-dinculescu committed Dec 17, 2023
1 parent 514046e commit 87bcbe8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@ file. This change log follows the conventions of

## [Rust Unreleased][Unreleased]

### Changed

- The `anyhow::anyhow!("Local hash does not match server hash")` error has been replaced with the more specific `tapo::TapoResponseError::InvalidCredentials` error.

## [Python Unreleased][Unreleased]

### Changed

- The `anyhow::anyhow!("Local hash does not match server hash")` error has been replaced with the more specific `tapo::TapoResponseError::InvalidCredentials` error.

## [Rust v0.7.6][v0.7.6] - 2023-11-25

### Added
Expand Down
7 changes: 4 additions & 3 deletions tapo/src/api/protocol/klap_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use async_trait::async_trait;
use isahc::cookies::CookieJar;
use isahc::prelude::Configurable;
use isahc::{AsyncReadResponseExt, HttpClient, Request};
use log::debug;
use log::{debug, warn};
use rand::rngs::StdRng;
use rand::{RngCore, SeedableRng};
use serde::de::DeserializeOwned;

use crate::requests::TapoRequest;
use crate::responses::{validate_response, TapoResponse, TapoResponseExt};
use crate::Error;
use crate::{Error, TapoResponseError};

use super::discovery_protocol::DiscoveryProtocol;
use super::klap_cipher::KlapCipher;
Expand Down Expand Up @@ -157,7 +157,8 @@ impl KlapProtocol {
let local_hash = KlapCipher::sha256(&[local_seed, remote_seed, auth_hash].concat());

if local_hash != server_hash {
return Err(anyhow::anyhow!("Local hash does not match server hash").into());
warn!("Local hash does not match server hash");
return Err(Error::Tapo(TapoResponseError::InvalidCredentials));
}

debug!("Handshake1 OK");
Expand Down

0 comments on commit 87bcbe8

Please sign in to comment.