vw_small

Hardened fork of Vaultwarden (https://github.com/dani-garcia/vaultwarden) with fewer features.
git clone https://git.philomathiclife.com/repos/vw_small
Log | Files | Refs | README

commit 62bc58e1453c885b15d3d56e4c50c985e2b9f4d2
parent 760e0ab805c3e7610777ddad2c7d8392b765c7c6
Author: Roman Hargrave <roman@hargrave.info>
Date:   Fri,  9 Nov 2018 00:27:43 -0600

Clean up after u2f endpoint split

Diffstat:
Msrc/api/core/two_factor.rs | 25++-----------------------
1 file changed, 2 insertions(+), 23 deletions(-)

diff --git a/src/api/core/two_factor.rs b/src/api/core/two_factor.rs @@ -252,23 +252,10 @@ fn generate_u2f(data: JsonUpcase<PasswordData>, headers: Headers, conn: DbConn) let user_uuid = &headers.user.uuid; let u2f_type = TwoFactorType::U2f as i32; - 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) - } - }; + let enabled = TwoFactor::find_by_user_and_type(user_uuid, u2f_type, &conn).is_some(); Ok(Json(json!({ "Enabled": enabled, - "Challenge": { - "UserId": headers.user.uuid, - "AppId": APP_ID.to_string(), - "Challenge": challenge, - "Version": U2F_VERSION, - }, "Object": "twoFactorU2f" }))) } @@ -283,15 +270,7 @@ fn generate_u2f_challenge(data: JsonUpcase<PasswordData>, headers: Headers, conn let user_uuid = &headers.user.uuid; - let u2f_type = TwoFactorType::U2f as i32; - 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) - } - }; + let challenge = _create_u2f_challenge(user_uuid, TwoFactorType::U2fRegisterChallenge, &conn).challenge; Ok(Json(json!({ "UserId": headers.user.uuid,