From 5f6d721c091029f02efd6bbacc57fa9847d95dc5 Mon Sep 17 00:00:00 2001 From: Kumar Ankur Date: Fri, 10 Aug 2018 23:19:07 +0530 Subject: [PATCH] Implemented PUT for /two-factor/authenticator and /two-factor/disable --- src/api/core/mod.rs | 2 ++ src/api/core/two_factor.rs | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/api/core/mod.rs b/src/api/core/mod.rs index a3d565c..3d130f3 100644 --- a/src/api/core/mod.rs +++ b/src/api/core/mod.rs @@ -66,8 +66,10 @@ pub fn routes() -> Vec { get_recover, recover, disable_twofactor, + disable_twofactor_put, generate_authenticator, activate_authenticator, + activate_authenticator_put, generate_u2f, activate_u2f, diff --git a/src/api/core/two_factor.rs b/src/api/core/two_factor.rs index 420362a..67088aa 100644 --- a/src/api/core/two_factor.rs +++ b/src/api/core/two_factor.rs @@ -112,6 +112,15 @@ fn disable_twofactor( }))) } +#[put("/two-factor/disable", data = "")] +fn disable_twofactor_put( + data: JsonUpcase, + headers: Headers, + conn: DbConn, +) -> JsonResult { + disable_twofactor(data, headers, conn) +} + #[post("/two-factor/get-authenticator", data = "")] fn generate_authenticator( data: JsonUpcase, @@ -194,6 +203,15 @@ fn activate_authenticator( }))) } +#[put("/two-factor/authenticator", data = "")] +fn activate_authenticator_put( + data: JsonUpcase, + headers: Headers, + conn: DbConn, +) -> JsonResult { + activate_authenticator(data, headers, conn) +} + fn _generate_recover_code(user: &mut User, conn: &DbConn) { if user.totp_recover.is_none() { let totp_recover = BASE32.encode(&crypto::get_random(vec![0u8; 20]));