geforkt von mirrored/vaultwarden
Clean up after u2f endpoint split
Dieser Commit ist enthalten in:
Ursprung
760e0ab805
Commit
62bc58e145
1 geänderte Dateien mit 2 neuen und 23 gelöschten Zeilen
|
@ -252,23 +252,10 @@ fn generate_u2f(data: JsonUpcase<PasswordData>, headers: Headers, conn: DbConn)
|
||||||
let user_uuid = &headers.user.uuid;
|
let user_uuid = &headers.user.uuid;
|
||||||
|
|
||||||
let u2f_type = TwoFactorType::U2f as i32;
|
let u2f_type = TwoFactorType::U2f as i32;
|
||||||
let register_type = TwoFactorType::U2fRegisterChallenge;
|
let enabled = TwoFactor::find_by_user_and_type(user_uuid, u2f_type, &conn).is_some();
|
||||||
let (enabled, challenge) = match TwoFactor::find_by_user_and_type(user_uuid, u2f_type, &conn) {
|
|
||||||
Some(_) => (true, String::new()),
|
|
||||||
None => {
|
|
||||||
let c = _create_u2f_challenge(user_uuid, register_type, &conn);
|
|
||||||
(false, c.challenge)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(Json(json!({
|
Ok(Json(json!({
|
||||||
"Enabled": enabled,
|
"Enabled": enabled,
|
||||||
"Challenge": {
|
|
||||||
"UserId": headers.user.uuid,
|
|
||||||
"AppId": APP_ID.to_string(),
|
|
||||||
"Challenge": challenge,
|
|
||||||
"Version": U2F_VERSION,
|
|
||||||
},
|
|
||||||
"Object": "twoFactorU2f"
|
"Object": "twoFactorU2f"
|
||||||
})))
|
})))
|
||||||
}
|
}
|
||||||
|
@ -283,15 +270,7 @@ fn generate_u2f_challenge(data: JsonUpcase<PasswordData>, headers: Headers, conn
|
||||||
|
|
||||||
let user_uuid = &headers.user.uuid;
|
let user_uuid = &headers.user.uuid;
|
||||||
|
|
||||||
let u2f_type = TwoFactorType::U2f as i32;
|
let challenge = _create_u2f_challenge(user_uuid, TwoFactorType::U2fRegisterChallenge, &conn).challenge;
|
||||||
let register_type = TwoFactorType::U2fRegisterChallenge;
|
|
||||||
let (enabled, challenge) = match TwoFactor::find_by_user_and_type(user_uuid, u2f_type, &conn) {
|
|
||||||
Some(_) => (true, String::new()),
|
|
||||||
None => {
|
|
||||||
let c = _create_u2f_challenge(user_uuid, register_type, &conn);
|
|
||||||
(false, c.challenge)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(Json(json!({
|
Ok(Json(json!({
|
||||||
"UserId": headers.user.uuid,
|
"UserId": headers.user.uuid,
|
||||||
|
|
Laden …
In neuem Issue referenzieren