Skip to content

Commit

Permalink
Merge pull request #617 from Stremio/fix/debug-for-auth-request-shoul…
Browse files Browse the repository at this point in the history
…d-hide-password

fix: AuthRequest Debug impl hides password
  • Loading branch information
elpiel authored Jan 25, 2024
2 parents 324ed76 + ce44d41 commit 014572e
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion src/types/api/request.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use core::fmt;

use crate::constants::{API_URL, LINK_API_URL};
use crate::types::addon::Descriptor;
use crate::types::library::LibraryItem;
Expand Down Expand Up @@ -128,7 +130,7 @@ impl FetchRequestParams<APIRequest> for APIRequest {
}
}

#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(test, derive(Derivative))]
#[cfg_attr(test, derivative(Default))]
#[serde(tag = "type")]
Expand All @@ -150,6 +152,37 @@ pub enum AuthRequest {
},
}

impl fmt::Debug for AuthRequest {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Login {
email,
password: _,
facebook,
} => f
.debug_struct("Login")
.field("email", email)
.field("password", &"<SENSITIVE>")
.field("facebook", facebook)
.finish(),
Self::Register {
email,
password: _,
gdpr_consent,
} => f
.debug_struct("Register")
.field("email", email)
.field("password", &"<SENSITIVE>")
.field("gdpr_consent", gdpr_consent)
.finish(),
Self::LoginWithToken { token } => f
.debug_struct("LoginWithToken")
.field("token", token)
.finish(),
}
}
}

#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
#[cfg_attr(test, derive(Derivative))]
#[cfg_attr(test, derivative(Default))]
Expand Down

0 comments on commit 014572e

Please sign in to comment.