Updated dependencies to use u2f crate directly, and some style changes

This commit is contained in:
Daniel García
2019-01-04 00:25:38 +01:00
parent c8af62ed48
commit 5f49ecd7f3
7 changed files with 110 additions and 114 deletions

View File

@ -78,7 +78,7 @@ fn register(data: JsonUpcase<RegisterData>, conn: DbConn) -> EmptyResult {
};
let claims: InviteJWTClaims = decode_invite_jwt(&token)?;
if &claims.email == &data.Email {
if claims.email == data.Email {
user
} else {
err!("Registration email does not match invite email")

View File

@ -287,23 +287,22 @@ struct EnableU2FData {
}
// This struct is copied from the U2F lib
// because challenge is not always sent
// to add an optional error code
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
struct RegisterResponseCopy {
pub registration_data: String,
pub version: String,
pub challenge: Option<String>,
pub error_code: Option<NumberOrString>,
pub client_data: String,
pub error_code: Option<NumberOrString>,
}
impl RegisterResponseCopy {
fn into_response(self, challenge: String) -> RegisterResponse {
fn into_response(self) -> RegisterResponse {
RegisterResponse {
registration_data: self.registration_data,
version: self.version,
challenge,
client_data: self.client_data,
}
}
@ -336,7 +335,7 @@ fn activate_u2f(data: JsonUpcase<EnableU2FData>, headers: Headers, conn: DbConn)
err!("Error registering U2F token")
}
let response = response_copy.into_response(challenge.challenge.clone());
let response = response_copy.into_response();
let registration = U2F.register_response(challenge.clone(), response)?;
// TODO: Allow more than one U2F device