use crate::ApiResponse; use crate::error::ApiError; use actix_web::{HttpResponse, Result, web}; use service::AppService; use service::auth::password::{ChangePasswordParams, ResetPasswordParams}; use session::Session; #[utoipa::path( post, path = "/api/auth/password/change", request_body = ChangePasswordParams, responses( (status = 200, description = "Password changed successfully", body = ApiResponse), (status = 401, description = "Unauthorized or invalid password", body = ApiResponse), (status = 400, description = "Bad request", body = ApiResponse), (status = 500, description = "Internal server error", body = ApiResponse), (status = 404, description = "Not found", body = ApiResponse), ), tag = "Auth" )] pub async fn api_user_change_password( service: web::Data, session: Session, params: web::Json, ) -> Result { service .auth_change_password(&session, params.into_inner()) .await?; Ok(crate::api_success()) } #[utoipa::path( post, path = "/api/auth/password/reset", request_body = ResetPasswordParams, responses( (status = 401, description = "Unauthorized", body = ApiResponse), (status = 200, description = "Password reset email sent", body = ApiResponse), (status = 404, description = "User not found", body = ApiResponse), (status = 500, description = "Internal server error", body = ApiResponse), ), tag = "Auth" )] pub async fn api_user_request_password_reset( service: web::Data, _session: Session, params: web::Json, ) -> Result { service .auth_request_password_reset(params.into_inner()) .await?; Ok(crate::api_success()) }