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

email.rs (1982B)


      1 use crate::{api::PasswordOrOtpData, auth::Headers, error::Error};
      2 use rocket::{serde::json::Json, Route};
      3 
      4 pub fn routes() -> Vec<Route> {
      5     routes![email, get_email, send_email, send_email_login]
      6 }
      7 
      8 #[derive(Deserialize)]
      9 #[serde(rename_all = "camelCase")]
     10 struct SendEmailLoginData {
     11     #[allow(dead_code)]
     12     #[serde(alias = "Email")]
     13     email: String,
     14     #[allow(dead_code)]
     15     #[serde(alias = "MasterPasswordHash")]
     16     master_password_hash: String,
     17 }
     18 const EMAIL_DISABLED_MSG: &str = "E-mail is disabled.";
     19 #[allow(unused_variables, clippy::needless_pass_by_value)]
     20 #[post("/two-factor/send-email-login", data = "<data>")]
     21 fn send_email_login(data: Json<SendEmailLoginData>) -> Error {
     22     Error::new(EMAIL_DISABLED_MSG, EMAIL_DISABLED_MSG)
     23 }
     24 
     25 #[allow(unused_variables, clippy::needless_pass_by_value)]
     26 #[post("/two-factor/get-email", data = "<data>")]
     27 fn get_email(data: Json<PasswordOrOtpData>, _headers: Headers) -> Error {
     28     Error::new(EMAIL_DISABLED_MSG, EMAIL_DISABLED_MSG)
     29 }
     30 
     31 #[derive(Deserialize)]
     32 #[serde(rename_all = "camelCase")]
     33 struct SendEmailData {
     34     #[allow(dead_code)]
     35     email: String,
     36     #[allow(dead_code)]
     37     master_password_hash: Option<String>,
     38     #[allow(dead_code)]
     39     otp: Option<String>,
     40 }
     41 
     42 #[allow(unused_variables, clippy::needless_pass_by_value)]
     43 #[post("/two-factor/send-email", data = "<data>")]
     44 fn send_email(data: Json<SendEmailData>, _headers: Headers) -> Error {
     45     Error::new(EMAIL_DISABLED_MSG, EMAIL_DISABLED_MSG)
     46 }
     47 
     48 #[derive(Deserialize)]
     49 #[serde(rename_all = "camelCase")]
     50 struct EmailData {
     51     #[allow(dead_code)]
     52     email: String,
     53     #[allow(dead_code)]
     54     token: String,
     55     #[allow(dead_code)]
     56     master_password_hash: Option<String>,
     57     #[allow(dead_code)]
     58     otp: Option<String>,
     59 }
     60 #[allow(unused_variables, clippy::needless_pass_by_value)]
     61 #[put("/two-factor/email", data = "<data>")]
     62 fn email(data: Json<EmailData>, _headers: Headers) -> Error {
     63     Error::new(EMAIL_DISABLED_MSG, EMAIL_DISABLED_MSG)
     64 }