From 6378d96d1ab26d84bc78d3e0e17294db9bf0a13b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Fri, 13 Jul 2018 11:07:20 +0200 Subject: [PATCH] Add some extra debug prints --- src/api/core/two_factor.rs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/api/core/two_factor.rs b/src/api/core/two_factor.rs index 083b8e0e..2669a8a1 100644 --- a/src/api/core/two_factor.rs +++ b/src/api/core/two_factor.rs @@ -269,12 +269,17 @@ fn activate_u2f(data: JsonUpcase, headers: Headers, conn: DbConn) ); if let Some(tf_challenge) = tf_challenge { - let challenge: Challenge = serde_json::from_str(&tf_challenge.data).unwrap(); + let challenge: Challenge = serde_json::from_str(&tf_challenge.data) + .expect("Can't parse U2fRegisterChallenge data"); + tf_challenge .delete(&conn) .expect("Error deleting U2F register challenge"); - let response: RegisterResponse = serde_json::from_str(&data.DeviceResponse).unwrap(); + println!("RegisterResponse {:#?}", &data.DeviceResponse); + + let response: RegisterResponse = + serde_json::from_str(&data.DeviceResponse).expect("Can't parse DeviceResponse data"); match U2F.register_response(challenge.clone(), response) { Ok(registration) => { @@ -349,7 +354,9 @@ impl Into for RegistrationCopy { } fn _parse_registrations(registations: &str) -> Vec { - let registrations_copy: Vec = serde_json::from_str(registations).unwrap(); + println!("Registrations {:#?}", registations); + let registrations_copy: Vec = + serde_json::from_str(registations).expect("Can't parse RegistrationCopy data"); registrations_copy.into_iter().map(Into::into).collect() } @@ -377,7 +384,10 @@ pub fn validate_u2f_login(user_uuid: &str, response: &str, conn: &DbConn) -> Api let challenge = match tf_challenge { Some(tf_challenge) => { - let challenge: Challenge = serde_json::from_str(&tf_challenge.data).unwrap(); + println!("challenge {:#?}", &tf_challenge.data); + + let challenge: Challenge = serde_json::from_str(&tf_challenge.data) + .expect("Can't parse U2fLoginChallenge data"); tf_challenge .delete(&conn) .expect("Error deleting U2F login challenge"); @@ -395,11 +405,8 @@ pub fn validate_u2f_login(user_uuid: &str, response: &str, conn: &DbConn) -> Api println!("response {:#?}", response); - let response: SignResponse = serde_json::from_str(response).unwrap(); - - println!("client_data {:#?}", response.client_data); - println!("key_handle {:#?}", response.key_handle); - println!("signature_data {:#?}", response.signature_data); + let response: SignResponse = + serde_json::from_str(response).expect("Can't parse SignResponse data"); let mut _counter: u32 = 0; for registration in registrations {