mirror of
				https://github.com/dani-garcia/vaultwarden.git
				synced 2025-10-31 02:08:20 +02:00 
			
		
		
		
	Actually use Device Type for mails (#4916)
- match Bitwarden behaviour - add a different segment in mails for Device Name
This commit is contained in:
		| @@ -269,8 +269,14 @@ pub async fn send_incomplete_2fa_notifications(pool: DbPool) { | ||||
|             "User {} did not complete a 2FA login within the configured time limit. IP: {}", | ||||
|             user.email, login.ip_address | ||||
|         ); | ||||
|         match mail::send_incomplete_2fa_login(&user.email, &login.ip_address, &login.login_time, &login.device_name) | ||||
|             .await | ||||
|         match mail::send_incomplete_2fa_login( | ||||
|             &user.email, | ||||
|             &login.ip_address, | ||||
|             &login.login_time, | ||||
|             &login.device_name, | ||||
|             &DeviceType::from_i32(login.device_type).to_string(), | ||||
|         ) | ||||
|         .await | ||||
|         { | ||||
|             Ok(_) => { | ||||
|                 if let Err(e) = login.delete(&mut conn).await { | ||||
|   | ||||
| @@ -265,7 +265,7 @@ async fn _password_login( | ||||
|     let twofactor_token = twofactor_auth(&user, &data, &mut device, ip, conn).await?; | ||||
|  | ||||
|     if CONFIG.mail_enabled() && new_device { | ||||
|         if let Err(e) = mail::send_new_device_logged_in(&user.email, &ip.ip.to_string(), &now, &device.name).await { | ||||
|         if let Err(e) = mail::send_new_device_logged_in(&user.email, &ip.ip.to_string(), &now, &device).await { | ||||
|             error!("Error sending new device email: {:#?}", e); | ||||
|  | ||||
|             if CONFIG.require_device_email() { | ||||
| @@ -421,7 +421,7 @@ async fn _user_api_key_login( | ||||
|  | ||||
|     if CONFIG.mail_enabled() && new_device { | ||||
|         let now = Utc::now().naive_utc(); | ||||
|         if let Err(e) = mail::send_new_device_logged_in(&user.email, &ip.ip.to_string(), &now, &device.name).await { | ||||
|         if let Err(e) = mail::send_new_device_logged_in(&user.email, &ip.ip.to_string(), &now, &device).await { | ||||
|             error!("Error sending new device email: {:#?}", e); | ||||
|  | ||||
|             if CONFIG.require_device_email() { | ||||
| @@ -535,7 +535,7 @@ async fn twofactor_auth( | ||||
|         return Ok(None); | ||||
|     } | ||||
|  | ||||
|     TwoFactorIncomplete::mark_incomplete(&user.uuid, &device.uuid, &device.name, ip, conn).await?; | ||||
|     TwoFactorIncomplete::mark_incomplete(&user.uuid, &device.uuid, &device.name, device.atype, ip, conn).await?; | ||||
|  | ||||
|     let twofactor_ids: Vec<_> = twofactors.iter().map(|tf| tf.atype).collect(); | ||||
|     let selected_id = data.two_factor_provider.unwrap_or(twofactor_ids[0]); // If we aren't given a two factor provider, assume the first one | ||||
|   | ||||
		Reference in New Issue
	
	Block a user