From 9713a3a5558d163fbade7d9260d8e994dbd9537b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomek=20Ma=C5=84ko?= Date: Sun, 13 Feb 2022 13:06:52 +0100 Subject: [PATCH] Add IP address to missing/invalid password message for Sends --- src/api/core/sends.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api/core/sends.rs b/src/api/core/sends.rs index 72437f15..ab1d7e9a 100644 --- a/src/api/core/sends.rs +++ b/src/api/core/sends.rs @@ -8,7 +8,7 @@ use serde_json::Value; use crate::{ api::{ApiResult, EmptyResult, JsonResult, JsonUpcase, Notify, NumberOrString, UpdateType}, - auth::{Headers, Host}, + auth::{ClientIp, Headers, Host}, db::{models::*, DbConn, DbPool}, util::SafeString, CONFIG, @@ -268,7 +268,7 @@ pub struct SendAccessData { } #[post("/sends/access/", data = "")] -fn post_access(access_id: String, data: JsonUpcase, conn: DbConn) -> JsonResult { +fn post_access(access_id: String, data: JsonUpcase, conn: DbConn, ip: ClientIp) -> JsonResult { let mut send = match Send::find_by_access_id(&access_id, &conn) { Some(s) => s, None => err_code!(SEND_INACCESSIBLE_MSG, 404), @@ -297,8 +297,8 @@ fn post_access(access_id: String, data: JsonUpcase, conn: DbConn if send.password_hash.is_some() { match data.into_inner().data.Password { Some(ref p) if send.check_password(p) => { /* Nothing to do here */ } - Some(_) => err!("Invalid password."), - None => err_code!("Password not provided", 401), + Some(_) => err!("Invalid password", format!("IP: {}.", ip.ip)), + None => err_code!("Password not provided", format!("IP: {}.", ip.ip), 401), } }