mirror of
				https://github.com/dani-garcia/vaultwarden.git
				synced 2025-10-31 10:18:19 +02:00 
			
		
		
		
	Allow changing error codes and create an empty error.
Return 404 instead of 400 when no accounts breached.
This commit is contained in:
		| @@ -33,10 +33,10 @@ use rocket::Route; | ||||
| use rocket_contrib::json::Json; | ||||
| use serde_json::Value; | ||||
|  | ||||
| use crate::db::DbConn; | ||||
|  | ||||
| use crate::api::{EmptyResult, JsonResult, JsonUpcase}; | ||||
| use crate::auth::Headers; | ||||
| use crate::db::DbConn; | ||||
| use crate::error::Error; | ||||
|  | ||||
| #[put("/devices/identifier/<uuid>/clear-token")] | ||||
| fn clear_device_token(uuid: String) -> EmptyResult { | ||||
| @@ -137,12 +137,13 @@ fn hibp_breach(username: String) -> JsonResult { | ||||
|  | ||||
|     use reqwest::{header::USER_AGENT, Client}; | ||||
|  | ||||
|     let value: Value = Client::new() | ||||
|         .get(&url) | ||||
|         .header(USER_AGENT, user_agent) | ||||
|         .send()? | ||||
|         .error_for_status()? | ||||
|         .json()?; | ||||
|     let res = Client::new().get(&url).header(USER_AGENT, user_agent).send()?; | ||||
|  | ||||
|     // If we get a 404, return a 404, it means no breached accounts | ||||
|     if res.status() == 404 { | ||||
|         return Err(Error::empty().with_code(404)); | ||||
|     } | ||||
|  | ||||
|     let value: Value = res.error_for_status()?.json()?; | ||||
|     Ok(Json(value)) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user