diff --git a/src/controllers/routes.rs b/src/controllers/routes.rs index a05bd6f..9668cf1 100644 --- a/src/controllers/routes.rs +++ b/src/controllers/routes.rs @@ -104,6 +104,7 @@ pub fn get_routes() -> Vec { Route::post("/settings/update_password", Box::new(settings_controller::update_password)), Route::post("/settings/get_account_image", Box::new(settings_controller::get_account_image_settings)), Route::post("/settings/upload_account_image", Box::new(settings_controller::upload_account_image)), + Route::post("/settings/delete_account_image", Box::new(settings_controller::delete_account_image)), // Friends controller diff --git a/src/controllers/settings_controller.rs b/src/controllers/settings_controller.rs index 682f769..8df34a2 100644 --- a/src/controllers/settings_controller.rs +++ b/src/controllers/settings_controller.rs @@ -2,6 +2,7 @@ //! //! @author Pierre Hubert +use crate::api_data::account_image_settings_api::AccountImageSettingsAPI; use crate::api_data::general_settings_api::GeneralSettingsAPI; use crate::api_data::language_settings_api::LanguageSettingsAPI; use crate::api_data::security_settings_api::SecuritySettingsAPI; @@ -14,7 +15,6 @@ use crate::data::security_settings::{SecurityQuestion, SecuritySettings}; use crate::data::user::UserPageStatus; use crate::helpers::{account_helper, user_helper}; use crate::helpers::virtual_directory_helper::VirtualDirType; -use crate::api_data::account_image_settings_api::AccountImageSettingsAPI; /// Get the general settings of the user pub fn get_general(r: &mut HttpRequestHandler) -> RequestResult { @@ -147,7 +147,7 @@ pub fn get_account_image_settings(r: &mut HttpRequestHandler) -> RequestResult { /// Upload a new account image pub fn upload_account_image(r: &mut HttpRequestHandler) -> RequestResult { if !r.has_file("picture") { - return r.bad_request("An error occurred while receiving the image !".to_string()) + return r.bad_request("An error occurred while receiving the image !".to_string()); } let uri = r.save_post_image("picture", "avatars", 800, 800)?; @@ -155,4 +155,11 @@ pub fn upload_account_image(r: &mut HttpRequestHandler) -> RequestResult { account_helper::set_account_image(r.user_id_ref()?, &uri)?; r.success("Account image updated!") +} + +/// Delete user account image +pub fn delete_account_image(r: &mut HttpRequestHandler) -> RequestResult { + account_helper::delete_account_image(r.user_id_ref()?)?; + + r.success("Account image deleted!") } \ No newline at end of file